On Wed, Apr 30, 2008 at 10:42:04PM +0200, Keryx Web wrote:
> Alain Williams skrev:
> >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)
> >
> >But I think that the first form is better.
> 
> From one whose job it is to daily *teach* PHP. The first form is very 
> much better.
> 
> And:
> 
> Suggestions to omit the word "function" altogether will be a nightmare 
> from a teaching point of view. Convenience for experienced programmers 
> should not come at the cost of unnecessary heightening of the threshold 
> for newcomers.

+1. We also don't want to break existing code or have two ways of doing
the same thing (that is perl's job :-) )

> And:
> 
> Once again, the main language besides PHP for most web developers is 
> JavaScript. Actionscript has been mentioned. The future of Actionscript 
> is ES 4. And from what I've recently read JavaScript is now the most 
> language used of all. Anyway, here's from Brendan E:
> 
> function f(a : int, b : String, c : Object) : RetType
> {
>   // arguments are guaranteed to match types
>   // return value must convert to or match RetType
> }

Nice in some ways, except that it is different from the way that type hinting
works in PHP5 classes - again: keep to one way of doing things.

': RetType' might be possible, but it is very different from where type hints
are given currently in PHP.

Stick with:

        function int &myfunction(int &$param)

> Personally I believe that the colon adds readability. *If* return type 
> hints are accepted I think this syntax is the best. (I do *not* think 
> PHP should add anything else from ES 4 when it comes to types.)

-- 
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>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to