Re:Things you should know about PHP 7
by Drakim on Thursday March 26, 2015 @10:21AM
(#9269776)
Haxe uses the first syntax, as does AS3. So it's not like "other languages" are universally opposed to this order.
[ Parent
| on HN ]
AFAICT both Haxe and AS3 consistently put types on the right, including argument declarations. Other languages consistently put it on the left. Most languages make a choice like that; PHP mixes things up a bit.
But then, it wouldn't be PHP if it was too consistent ;).
Re:Things you should know about PHP 7
by TazeTSchnitzel on Thursday March 26, 2015 @10:54AM
(#9270028)
To be fair, it's not the same as an argument type. The type of `foo()` isn't int, it's function. You're not specifying the type of the thing itself, merely the type of what it returns. Though this seems to have been lost on the creators of C. ;)
sure but AS3, Go Haxe and others ARE consistant
function foo(a:int,b:string):bool{}
in PHP this will be function foo(int a,string b):bool{}
Re:Things you should know about PHP 7
by notacoward on Thursday March 26, 2015 @12:11PM
(#9270685)
Putting the type first for parameters and last for return values seems like exactly the same kind of inconsistency that has already earned PHP plenty of criticism. Personally I kind of like the Pascal style, I use the C style all day every day, but mixed style seems like the worst option available.
Rust also has this syntax if I remember correctly, for parsing reason
Re:Things you should know about PHP 7
by pilsetnieks on Thursday March 26, 2015 @10:32AM
(#9269853)
Go also has a similar syntax (except the colon)