I don't know if other languages have both dynamic and sealed classes
at once, but I have come across occasions in ActionScript where it can
cause a problem. The mutability of a dynamic class is seen as part of
its interface, and subclasses that are not dynamic will break code
that depends on it.

    dynamic class A { }
    class B extends A { }

    var a:A;
    a["some key"] = 1; // will throw an error if a is B


In AS3, "dynamic" is not inherited, but even if it was inherited there
would be a corresponding "sealed" keyword to prevent having to make a
special case of Object being dynamic but subclasses not, so there
would always be the possibility of this situation.


I feel there is a need for a way to declare that a variable must be of
a dynamic type. The best syntax I could envisage would be  for
"dynamic" to indicate a dynamic pseudo-type, when it is used in a type
expression. But it would be quite crippled without having intersection
types too.


One to come back to for ES5?

Peter
_______________________________________________
Es4-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es4-discuss

Reply via email to