Re: [RFC][Discuss] Arrow Functions

From: Date: Tue, 30 May 2017 18:08:29 +0000
Subject: Re: [RFC][Discuss] Arrow Functions
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to internals+get-99272@lists.php.net to get a copy of this message
Den 2017-05-30 kl. 17:09, skrev Levi Morrison:
Well, my preference would be for alternative 3. Not in favour of 2 & 4. Nr 1 not so sure about and for nr 5, maybe tweak it to:
- [](params) ==> expr    // binds no values
- [=](params) ==> expr    // binds by value
- [&](params) ==> expr    // binds by reference
Can you explain why you want a longer arrow? To improve readability and also make it less ambiguous for
the programmer / reader of code. Also I think it stands out more in code reviews and if one by mistake looses [], would it then generate a parsing error or be treated as valid syntax. Maybe also a bit simpler to implement then "[]() => expr" in the PHP engine, but I'm guessing on this one though...
Leaving out [] could also be a default:
- (params) ==> expr    // binds no values
Or maybe that is why? Yup, one reason!
I presume then that the options discussed earlier "|params| => expr" and "lamda(params) => expr" are of the table.
The |params| => expr syntax is off the table, yes. I don't remember anyone taking the lambda(params) => expr suggestion seriously; my apologies if I'm simply remembering this incorrectly. I recall some liking it (like me ;-) since it's a clearer signal
then fn(params) that we have something different here. r//Björn

« previous php.internals (#99272) next »