Class method addition and replacement (was Re: AOP Compatibility)

Kris Zyp kris at sitepen.com
Thu Apr 3 08:23:04 PDT 2008


>> the moment, but I assume you can't do replace a method on a user  class 
>> with
>> another ad-hoc function.
>
> Absolutely not with fixtures,

I was thinking about this, is there any reason why you can't replace a 
class's method with another method or install a method on an instance object 
that overrides the class's method, assuming that the method signature 
remains the same, the body has correct typing use of |this|, and the class 
is non-final? This seems to have the same integrity as method overriding in 
subclasses. Being able to do this (and possibly dynamically adding methods 
to classes) would bring the level of dynamicism that Mark had suggested with 
his ES4 sugar proposal (being able to create classes on the fly), but 
without destroying the fundamental ES4 typing/fixture system. This could be 
used to solve AOP as well, and bring a distinctly higher level of dynamicism 
which could be leveraged to progressively build, serialize (with proper 
introspection), and deserialize classes.

Essentially, are there mutations to classes and object instances that do not 
effect integrity and do not violate explicit contracts against mutation 
(final annotation=no method mutations) that we could allow?

Thanks,
Kris




More information about the Es4-discuss mailing list