Lexical versus dynamic "this"
Axel Rauschmayer
axel at rauschma.de
Tue May 10 16:31:24 PDT 2011
Quoting Andrew Dupont:
> (b) the ->/=> distinction is, I think, too subtle. Rebinding dramatically changes the meaning of the function, so I'd prefer if the notation guaranteed that a user couldn't gloss over that by mistaking -> for => or vice/versa.
I agree. Are newbies ever going to be able to handle this? If we are going to overhaul function semantics, wouldn’t it make sense to adopt a more explicit approach?
> myfunc(param1, param2) -> { ... } // lexical this
> var obj = {
> mymethod: (this, param1, param2) -> { ... } // dynamic this
> }
This is how Python handles methods. I think there were objections to this approach, but unfortunately I can neither remember them nor find them online.
I think I’ll get used to the infix operator, but would prefer if it could be prefix (easier on *my* eyes, easier to parse, closer to current syntactic style). Is the backslash already taken?
\(x,y) x + y
#\(x) x +y // frozen
--
Dr. Axel Rauschmayer
axel at rauschma.de
twitter.com/rauschma
home: rauschma.de
blog: 2ality.com
More information about the es-discuss
mailing list