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.

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
}

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


Lars Gunther

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

Reply via email to