Re:Hack: a new programming language for HHVM
by devwebee on Thursday March 20, 2014 @01:04PM
(#7436894)
It looks promising, I highly dislike writing PHP and this seems like it might ease the pain, but they could've gotten rid of the damn dollar sign in front of variables, how ugly is this? "return ($y) ==> { return $y + 1; }"
[ Parent
| on HN ]
Re:Hack: a new programming language for HHVM
by dparoski on Thursday March 20, 2014 @02:28PM
(#7437583)
Engineer working on Hack here.
You can actually write you example a bit more concisely in Hack: "$y ==> $y + 1".
Re:Hack: a new programming language for HHVM
by iso8859-1 on Friday March 21, 2014 @03:51AM
(#7441144)
Return statements are optional? So it's just the last statement in a function that'll get returned?
Re:Hack: a new programming language for HHVM
by dparoski on Friday March 21, 2014 @06:53PM
(#7445487)
The "return" keyword is not needed if the right hand side of the lambda arrow ("==>") is an expression that is not wrapped in curly braces.
If the right hand side _is_ wrapped in curly braces then it is treated as a list of statements, in which case you do need to use the "return" keyword.
Re:Hack: a new programming language for HHVM
by dparoski on Saturday March 22, 2014 @02:52AM
(#7448078)
Edit: My previous comment was referring to the second occurrence of "return" in your example (after the "==>" arrow). Just noticed I mistakenly dropped the first occurrence of "return"; the first occurrence of "return" in your example is needed.