Question about joined function object of ECMA-262 3rd edition

Neil Mix nmix at pandora.com
Thu Jul 26 14:52:30 PDT 2007


Wait, am I following this correctly in that:

function A() {
	function B() {}
	return B;
}

var x = A();
var y = A();

x.foo = 1;
y.foo = 2;

alert(x.foo + y.foo);

would show "3" in current compliant implementations, but  
theoretically in the future an implementation could exist that would  
show "4" and *still be compliant*?  If I'm surmising correctly, then  
that seems...buggy.

On Jul 26, 2007, at 4:33 PM, John Cowan wrote:

> liorean scripsit:
>
>> A could have any number of local variables, b1 and b2 could still be
>> joined. The important factor is that it doesn't use variables from  
>> the
>> containing scope(s), so there is no observable difference.
>
> Yes, that is what I meant.
>
>> If any implementation would chose to do the joined objects behaviour,
>> are they not more likely to actually just use a reference to the same
>> function object instead of joining two different objects?
>
> Quite so; as I said, the difference between joined and being the same
> is irrelevant in this context, and indeed an internal detail of the
> implementation.
>
>> However, I think the compiler complexity added for implementing this
>> will give a negliable reduction in footprint, so most implementors
>> haven't found it worthwile to do it.
>
> So far.  Eventually, someone will write an "ahead-of-time" compiler
> in the style of typical Lisp compilers, where such things matter.
>
> -- 
> My confusion is rapidly waxing          John Cowan
> For XML Schema's too taxing:            cowan at ccil.org
>     I'd use DTDs                        http://www.ccil.org/~cowan
>     If they had local trees --
> I think I best switch to RELAX NG.
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss




More information about the Es4-discuss mailing list