Method definitions in classes/objects

Allen Wirfs-Brock allen at wirfs-brock.com
Mon Oct 8 09:33:12 PDT 2012


On Oct 8, 2012, at 9:20 AM, Erik Arvidsson wrote:

> On Mon, Oct 8, 2012 at 11:54 AM, Allen Wirfs-Brock
> <allen at wirfs-brock.com> wrote:
>> I don't believe that we have discussed, at a meeting, property name capture
>> (other than WRT super) of ConciseMethod definitions.  It is however,
>> something that I have thought about  quite a bit.  Concise methods, as
>> currently specified, do not create a local binding for the property name
>> whose value is the function.
> 
> I think we talked about this when we talked about concise methods in
> object literals, before classes where approved.
> 
> A local binding would only be added of the name was an identifier
> 
>> However, these issues could be dealt with and and I've always seen this as a
>> pretty close call.  Are there strong use cases for giving methods a
>> FunctionExpression-like binding of the property name?
> 
> In classes I don't think it matters much, because it is most likely
> the wrong to use the function without this.

this that was definitely a factor in my choice of semantics:

//bad
class foo {
     recursive(p) {return recursive(f(p))}
}

//good
class foo {
   recursive(p) {return this.recursive(f(p))}
}

Allen






More information about the es-discuss mailing list