Jeff, Can I tease out a bit more detail. I'm not sure I agree with what the correct answer should be.
Lars raised the issue with "var" a while back and I think, if my memory serves me, the conclusion was that the variable should be hoisted to the top of the var block, but the initialization statement should execute in place. ie. => declaration for y hoisted to here print(y) // Y should exist here but be null x = 1 var y = x // Assigment from x remains here If the above is true for variables, should we not have the same rules for functions and for classes? ie. shouldn't class static initialization code remain inline where the class is defined? I'd recommend that we make var,function and class all behave the same way. Does any of the above change if enclosed in a package block? I presume the class declaration should be hoisted to the top of the package block. But still, the initialization remain inline where the class was declared. Michael On Apr 15, 2008, at 11:58 AM, Jeff Dyer wrote: > This is an RI bug too (my fault). AS3 initializes programs in a > single pass, > before evaluating the top level code. The RI does both in one pass. > I just > filed a bug (http://bugs.ecmascript.org/ticket/382) > > Jd > > On 4/15/08 11:38 AM, Michael O'Brien wrote: > >> Jon, thanks. Any thoughts on the original post? >> >> >>>>> Question about declarations: >>>>> >>>>> Consider: >>>>> >>>>> print(Shape.x) >>>>> public class Shape { public static var x = 1; } >>>>> print(Shape.x) >>>>> >>>>> fun() >>>>> function fun() { print("fun"); } >>>>> >>>>> >>>>> In the RI this prints: >>>>> >>>>> undefined >>>>> 1 >>>>> fun >>>>> >>>>> In ASC this prints: >>>>> 1 >>>>> 1 >>>>> fun >>>>> >>>>> What happens in the RI is the class declaration seems to occur >>>>> where >>>>> it is coded. It is not being >>>>> hoisted to the top of the enclosing var block. Whereas the >>>>> function >>>>> declaration is and thus can >>>>> be called before its declaration. >>>>> >>>>> Is this an RI bug or just a divergence from AS3? >>>>> >>>>> Michael >>>> >>>> _______________________________________________ >>>> Es4-discuss mailing list >>>> [email protected] >>>> https://mail.mozilla.org/listinfo/es4-discuss >>>> >>>> >> >> _______________________________________________ >> Es4-discuss mailing list >> [email protected] >> https://mail.mozilla.org/listinfo/es4-discuss > _______________________________________________ Es4-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es4-discuss
