Private Names and Methods

Allen Wirfs-Brock allen at wirfs-brock.com
Thu Apr 5 13:44:52 PDT 2012


On Apr 5, 2012, at 12:48 PM, Kevin Smith wrote:

> Hi Allen,
> 
> I completely agree with everything you wrote, and with the transformations necessary to correctly perform the refactoring I'm talking about.
> 
> The transformation is still too low-level though.  In order to perform it, we have to switch from thinking in terms of methods to functions and back again.  It would be preferable if the mismatch weren't so great.
> 
> Would something like Dave's bind operator be applicable here?
> 
>     M1() {
>       ...
>       this::helperMethod();
>       ...
>     }
> 
> 

Not really. For that to work helperMethod would still have to be declared via a in scope function declaration and rather than as a method in the same class or object literal as M1.  In that case, it really isn't a method and shouldn't be named  as such or use a this reference.  All the bind (or call/apply) is saving is the renaming of any "this" references in the original <C> fragment. But you should want to do that renaming because the helper is no longer a method so making it a function that references "this" would just be a likely source of confusion concerning the intended use of the function

Allen




More information about the es-discuss mailing list