royale-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <>
Subject Re: Static inheritance
Date Tue, 24 Apr 2018 07:03:50 GMT
Well, without a clear picture on how to emulate these ES6 static method features in ES5, you
might have better luck porting to the Singleton pattern and avoid static method inheritance.

Also read this:

My 2 cents,

From: Harbs <>
Reply-To: "" <>
Date: Monday, April 23, 2018 at 11:43 PM
To: "" <>
Subject: Re: Static inheritance

Not sure. Less boilerplate code?

On Apr 24, 2018, at 9:41 AM, Alex Harui <<>>

What are the advantages of static over the singleton pattern?


From: Harbs <<>>
Reply-To: "<>" <<>>
Date: Monday, April 23, 2018 at 1:30 PM
To: "<>" <<>>
Subject: Re: Static inheritance

Nope. It does not work in AS3 targeting JS either because it’s a ES6-only feature.

On Apr 23, 2018, at 11:28 PM, Carlos Rovira <<>>

Ok, so that works in JS, but will work as well in SWF?

2018-04-23 20:25 GMT+02:00 Harbs <<>>:<><><>

UniversalShaper and ArabicShaper extend DefaultShaper. All methods are static and the classes
are never instantiated. The static “plan” method in the base class calls the static methods
in the subclasses using “this”.

I would not have guessed something like this would be possible, but Devon Govett makes very
extensive use of ES6 features. I’ve learned quite a bit about ES6 just by reading his code…


On Apr 23, 2018, at 8:25 PM, Alex Harui <<>>


Can you provide a link to more info on how 'this' works in statics?  MDN makes it sound like
it points to the global object even in ES6.

I saw an article that code duplication isn't a perfect emulation of ES6 statics in ES5.<>

On 4/22/18, 11:46 PM, "Harbs" <<>>

   It seems like ES6 supports static inheritance. The means you can define a class with static
methods which can be called in subclasses. You can also use “this” in static methods which
will refer to the subclass methods if overridden. This is obviously something which doesn’t
work in AS3.

    I’m porting an ES6 library to AS3 and I’m trying to figure out the best way to port
this kind of code. I’m thinking that code duplication is probably simplest, although I might
just convert the static classes into singletons.


Carlos Rovira<>

View raw message