lz.state is more messed up than that. If you look at the comment on
lz.state#setApply, you will see that state even defines its own apply
_method_... so it conflicts with itself!
One thing: In JS2, `override` is used on the overriding method, not
the overridden method. To declare that a method cannot be overridden
you say 'final' on the method (or, the whole class). But, I don't
like 'final' annotations[*]:
a) It means the designer of the class has to consider _all_ possible
future extensions of their class, or
b) It means that someone who needs to extend the class will end up by
duplicating the class instead.
So, I don't think we should be annotating the superclass this way.
If we were to pursue this, we should have the compiler warn you when
you override any superclass method, and let you declare your intent
(silence the warning) by adding an 'override' property to your
method. Conversely, if you declare your method to be 'override', the
compiler should warn you if there is no superclass method of the same
name.
I have code in the runtime to do this, but we would need to extend
the script parser to handle the override annotation.
---
[*] A better solution is Dylan's sealed/open annotation. Basically
the same idea, but it applies to the module extensibility, rather
than on a per-class basis. And, you can provide an open subclass of
your sealed class, permitting extensibility when it is needed.
On 2007-10-22, at 00:38 EDT, Henry Minsky wrote:
I decided to try adding a "override" flag as an explicit syntax for
protecting some of the important base methods in lfc.lzx. The idea
being
that trying to override these methods in a LZX class will flag a
compiler
warning.
<interface name="Instance" extends="Object">
<method name="validateClassStructure" override="false"/>
<method name="initialize" override="false"/>
<method name="nextMethod" override="false"/>
<method name="addProperty" override="false"/>
<method name="constructor" override="false"/>
<method name="hasOwnProperty" override="false"/>
<method name="isPropertyEnumerable" override="false"/>
<method name="isPrototypeOf" override="false"/>
<method name="toLocaleString" override="false"/>
<method name="prototype" override="false"/>
<method name="apply" override="false"/>
<method name="call" override="false"/>
</interface>
When I started getting the method-override warnings working
properly for
real, I got this warning, which is a real issue:
C:/users/hqm/openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx:505:40: In
class
'state' attribute 'apply' with type 'boolean' is overriding superclass
attribute with same name but different type: _method_
Indeed, we probably should not be defining a method named "apply"
on state.
Maybe we should think
about changing the name of this in future versions?
In the meantime , I guess I'll remove the "override=false' flag from
'apply'...
--
Henry Minsky
Software Architect
[EMAIL PROTECTED]