[Laszlo-dev] For Review: Change 20071217-ptw-6 Summary: Class support for swf9
Donald Anderson
dda at ddanderson.com
Tue Dec 18 12:34:20 PST 2007
On Dec 18, 2007, at 1:59 PM, P T Withington wrote:
> On 2007-12-18, at 09:30 EST, Donald Anderson wrote:
>
>> Approved.
>> It compiles with SWF9 compiler, modulo the 'const' statement
>> (known compiler deficiency).
>
> So can the compiler change const to var on output?
It could, I haven't done that yet.
>> Question, with this comment:
>> public static function initialize (prototype:Object):void {
>> // @devnote: Subclasses must have this as their first line:
>> // prototype.constructor.initialize.call(this, prototype);
>> }
>>
>> This is a problem mentioned before - a static function cannot
>> reference 'this'. Did we have a workaround for that?
>> I mentioned using 'prototype.constructor' instead of 'this' - would
>> that work?
>
> Sorry, where I wrote `this`, I should have said <subclass>. So in a
> subclass:
>
> class Subclass extends whatever {
> public static function initialize (proto:Object):void {
> // Inserted by the compiler:
> proto.constructor.initialize.call(Subclass, proto);
> ~~~
> }
>
> And as we discussed on the phone in the constructor:
>
> public function Subclass (~~~) {
> ~~~
> this.initialize.apply(this, arguments);
> }
>
> NOTE: there is a bug in AS3 where `arguments` will not be defined if
> `...rest` is used. So, perhaps it will be better to say:
>
> public function Subclass (<formals>) {
> ~~~
> this.initialize.call(this, <formal id's>);
> }
>
> I.e., explicitly list the arguments by getting the id's out of the
> formal parameter list.
>
>
Okay, will do.
>> Another question - supposing I know the 'magic' to auto-insert into
>> the initialize method - can I blindly insert one (i.e. safe to call
>> it twice?)
>
> No, it would not be safe. But, it would be an error for the
> programmer to call the initialize method themselves. Let's not
> worry about that detail at this point.
Okay.
--
Don Anderson
Java/C/C++, Berkeley DB, systems consultant
voice: 617-547-7881
email: dda at ddanderson.com
www: http://www.ddanderson.com
More information about the Laszlo-dev
mailing list