Closed btwael closed 11 years ago
I agree, especially since functions can be assigned to variables in php:
$square = function($x) {
return $x * $x;
};
echo $square(2);
@nubs , This feature are added to Mammouth. see this issue: #5
by Hector Virgen on Google+ Very cool! Two suggestions:
Using = to declare functions makes it look too much like the function is being assigned to a variable. You may want to try a different syntax, e.g.:
square: (x) -> return x * x
Or more simply, use -> as a hint that a function is being defined:
square(x) -> return x * x
Additionally, you can borrow some ideas from coffescript and ruby by automatically returning the last statement:
square(x) -> x * x
I believe your idea of a php preprocessor has a lot of potential. Php syntax, although C-like, is pretty terrible for rapid development. Something like Mammouth can really clean things up.