On Fri, Aug 1, 2008 at 1:03 PM, Maciej Stachowiak <[EMAIL PROTECTED]> wrote:
>
> On Jul 31, 2008, at 5:24 AM, Dave Herman wrote:
>
>>> We should take this problem seriously. ...
>>>
>>> Dynamic scope is very bad.
>>
>> Specifically:
>>
>> - Classes are supposed to provide integrity, but dynamic scope makes
>> the
>> internals of code brittle; any variable reference inside the
>> implementation could be subverted by the seemingly innocuous insertion
>> of a property.
>>
>> - Dynamic dispatch has a reasonably understandable cost model, but
>> only
>> if it's confined to explicit property references. With dynamic scope,
>> any variable reference could potentially be very expensive.
>>
>> - Generally, code within a `with' block is brittle and hard to
>> understand, and as Tucker says, the implicit `this.' means that all
>> code
>> inside class methods is within a `with' block... this means that all
>> code inside class methods is brittle!
>>
>> - In the past, this has been enough for many programmers to deprecate
>> all use of `with' -- we should certainly hope to avoid the same
>> happening for classes.
>
> I'm not sure of the benefits on the whole of implicit 'this' for class
> methods, but isn't it plausible to apply it only to static properties
> and not dynamically inserted ones,
What is dynamically inserted? I guess would mean properties added to
an instance of a non-sealed class.
> so all references continue to be
> bound at compile time and this sort of brittleness does not come up?
>
I think I remember discussion that 'this' in a static context was not valid.
If 'this' in a static context points to the class itself, it allows
for the possibility of the class having a static method, with a
private constructor and a public getInstance method with code
something like:
>> class E { static function f(){ return new this; } }
>> E.f()
[object E]
Works in the RI.
But I there was apparently a reason that that was not good, so that is a bug.
http://bugs.ecmascript.org/ticket/74
Garrett
> Regards,
> Maciej
_______________________________________________
Es4-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es4-discuss