9.6.2 - 'this' or 'super' in a static method

Peter Hall peter.hall at memorphic.com
Sun Aug 19 07:16:44 PDT 2007


On 8/17/07, Garrett Smith <dhtmlkitchen at gmail.com> wrote:
> 9.6.2 It is an error for the 'this' or 'super' expression to appear in
> the body of a static method.
>
> 1. Is this error mentioned a compile-time error?

Compile-time. In general, any error that can be detected at
compile-time is a compile-time error.

> 2. Why does 'this' in a static method generate an error? (it shouldn't
> refer to the class?)

'this' always refers to an instance. Inside a class, it would be
confusing if 'this' refers sometimes to the instance and sometimes to
the class, depending on one attribute of the containing method.

Cormac, could the Self Proposal be extended here to allow 'Self' (or
my preference, 'this type') to refer to the class in this context?


Peter



More information about the Es4-discuss mailing list