block lambda revival, now with semantics
Jorge
jorge at jorgechamorro.com
Mon May 23 07:06:14 PDT 2011
On 23/05/2011, at 07:15, Kam Kasravi wrote:
> Is this valid?
>
> function Person(a) {
> this.age = a;
> }
> Person.prototype.myage = {|| this.age};
>
> function info(myage) {
> console.log('my age is '+myage());
> }
> info(new Person(10).myage);
> info(new Person(12).myage);
If it's valid (I don't know if there can be a block-lambda standing alone outside of a function), it would return the value of the global variable `age`, I think, because the enclosing scope's `this` in that code above seems to be the global Object.
Brendan, do you really want these block-lambdas to be blocks?
I thought you were just going to borrow its syntax for shorter function(){} semantics, not blocks semantics ?
What if {||} were just the shorter function syntax we want, with the added features we want (completion value as return value, lexical/dynamic `this`, ... ?), but not true blocks ?
--
Jorge.
More information about the es-discuss
mailing list