Scoped binding of a method to an object

Allen Wirfs-Brock allen at wirfs-brock.com
Mon Oct 14 10:52:22 PDT 2013


On Oct 14, 2013, at 8:42 AM, Brendan Eich wrote:

> Andreas Rossberg wrote:
>> My take-away was that scoped extension methods are only bearable in a
>> language with a static, nominal class system (like C#), where the
>> additional lookup dimension can be resolved at compile time.
> 
> Right.
> 
> The http://scg.unibe.ch/archive/papers/Berg03aClassboxes.pdf work, which inspired Ruby refinements as well as the scoped object extensions strawman, is about Smalltalk. For all its dynamic typing, Smalltalk has nominal class types and static method membership judgements.
> 
> Based on the research, it seems to me that if we want this in JS, we should look at how to build it on ES6 classes + modules.

I'm not sure I buy your "Smalltalk has nominal class types" assertion, but Smalltalk does generally process class definitions as a complete unit and certain dynamic changes to a class definition can cause the complete reprocessing (eg, recompiling methods from source)  of a class and all of its subclasses (and the dynamic mutation of all existing instances of those classes!) to match the revised definition.  The reprocessing can also fail if the change introduces any inconsistencies such as deleting instances variables that are still referenced by methods.

I believe that classboxes depends upon this reprocessing step to maintain its invariants. 

Allen


More information about the es-discuss mailing list