[Redirected to laszlo-dev]

On 2008-08-12, at 00:01EDT, Henry Minsky wrote:

As I am here implementing the fix for LPP-6741 [tag compiler needs to track names when compiling named children in states], it occurred to me that maybe there is a way to be using mixins to implement states, instead of the special
case compiler code that we have now.

This particular bug is that you cannot refer to named children using
instance vars in swf9 unless
those child names are declared at compile time. And it occurred to me that
if we were using mixins,
then named children would automatically be declared as instance vars using
the existing
mixin compiler machinery.

What also occurred to me, in a more vague unformed way, is that expecting
the named children to
appear as instance vars from states using the current "dynamic"
implementation is kind of
a sloppy and dangerous thing to depend on, and is not really conducive to
"programming in the large"
or "structured programming" or whatever we would call it when lightweight
scripting languages
start tripping up the developers who are trying to build larger systems. The
meta-issue is that we are
allowing modularity violations by making people refer to names of child
views as if they are instance vars, when
they are not really instance vars of classes, and then doing all this hair
to fix that up in the compiler. It
would probably be safer and simpler for the developers if we could make
states be implemented
as genuine mixins, then there would be less magic and we could probably get
the same functionality without
more special compiler hacks.

[Aside: A mixin is a 'classy' thing (is-a), and a state is a 'prototypical' thing (has-a). Both mechanisms are Turing-equivalent, you can implement each in terms of the other. We've gone to great pains to implement (JS2) classes on top of a prototype language (JS1). It's interesting that you want to take one of the remaining prototype features and implement it in terms of classes.]

What about the issue of placement? While your mixin idea works for the lexical parent, I don't see how it can work for the dynamic parent, when the state is subject to placement. Making state a mixin would be more honest in some sense, since a state is not a node, its methods and children get donated to its parent. Hm. When a state is placed, do its methods and children belong to both the lexical and dynamic parent? Or are they really only on the lexical parent?

Reply via email to