176Re: [caplet] Mutability of functions in ECMAScript
- Apr 6, 2008> If functions were immutable, joining would be a transparent optimization.
>Apart from the theoretical potential for backward incompatibility, why
>isn't this a better solution? I suspect that very few programs rely on
>mutating actual functionsReally? It is actually even used in ADsafe's core library. Mutating functions is pretty core functionality, and AFAIK it is necessary to form multi-level prototypical inheritance. If I want object A to delegate/inherit from preexisting object B, I must create a function and set the prototype (a mutation) to object B and then construct with that function. See the beget function in ADsafe.I would extremely surprised if function mutation is less common than some of the things that the ES3.1 and ES4 groups have to maintain for backwards compatibility (the latest was being able override the Error built-in). I have used it other situations as well, like using storing a list of listeners on a AOP advising function. AOP style event listeners are common in popular JS libraries as well, and I would imagine they use such techiniques as well.> (as opposed to creating mutable objects that are
> callable as functions, ormutating Function.prototype) .How do make a regular object callable?Kris----- Original Message -----From: David-Sarah HopwoodSent: Sunday, April 06, 2008 9:17 AMSubject: Re: [caplet] Mutability of functions in ECMAScript
Mark Miller wrote:
> On Sat, Apr 5, 2008 at 9:09 PM, Kris Zyp <kris@sitepen. com> wrote:
>> AFAIK, no implementation has ever actually done this "joining", and I
>> believe ES3.1 and ES4 will very likely dissallow joining to prevent it from
>> ever happening in the future.
> Yes, that's what we decided. ES3.1 and ES4 will be deterministic in
> this regard. No joining.
If functions were immutable, joining would be a transparent optimization.
Apart from the theoretical potential for backward incompatibility, why
isn't this a better solution? I suspect that very few programs rely on
mutating actual functions (as opposed to creating mutable objects that are
callable as functions, or mutating Function.prototype) .
- << Previous post in topic Next post in topic >>