Re: Return type hinting patch
| From: | Sam Barrow | Date: | Wed, 30 Apr 2008 11:50:57 +0000 |
| Subject: | Re: Return type hinting patch | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-37349@lists.php.net to get a copy of this message | ||
On Wed, 2008-04-30 at 08:27 +0100, Alain Williams wrote:
> On Wed, Apr 30, 2008 at 09:23:17AM +0300, Arvids Godjuks wrote:
> > I'm +1 for this syntax
> >
> > function int myfunction(int $param)
> > {
> > return $someint;
> > }
> >
> > C/C++ like, easy to understand
>
> +1 -- least confusion to most people.
>
> Taking it a bit further, if the function returns a reference (eg to its argument):
>
> function int &myfunction(int &$param)
>
> Alternative could be:
> function &int myfunction(int &$param)
I like this better, I think this would just be a matter of ordering
arguments in the parser.
> But I think that the first form is better.
>
> > And bad idea about making a return type "function" - looks very useless and
> > will not be used a lot. Work with objects with methods returning an object
> > of some kind, then you can do
> >
> > $object->method()->method2()->method3();
> >
> > P.S. I think this thread should be merged with function param type hinting
> > because they come together and should be implemented together,
>
> Sam has done much work on param type hinting, we should thank him for his hard work.
>
> --
> Alain Williams
> Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
> +44 (0) 787 668 0256 http://www.phcomp.co.uk/
> Parliament Hill Computers Ltd. Registration Information:
> http://www.phcomp.co.uk/contact.php
> Chairman of UKUUG: http://www.ukuug.org/
> #include <std_disclaimer.h>
>