You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@royale.apache.org by Harbs <ha...@gmail.com> on 2018/04/23 06:46:11 UTC

Static inheritance

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.

Harbs

Re: Static inheritance

Posted by Alex Harui <ah...@adobe.com>.
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: https://softwareengineering.stackexchange.com/questions/34485/what-is-the-difference-between-all-static-methods-and-applying-a-singleton-patte

My 2 cents,
-Alex

From: Harbs <ha...@gmail.com>
Reply-To: "users@royale.apache.org" <us...@royale.apache.org>
Date: Monday, April 23, 2018 at 11:43 PM
To: "users@royale.apache.org" <us...@royale.apache.org>
Subject: Re: Static inheritance

Not sure. Less boilerplate code?

On Apr 24, 2018, at 9:41 AM, Alex Harui <ah...@adobe.com>> wrote:

What are the advantages of static over the singleton pattern?

-Alex

From: Harbs <ha...@gmail.com>>
Reply-To: "users@royale.apache.org<ma...@royale.apache.org>" <us...@royale.apache.org>>
Date: Monday, April 23, 2018 at 1:30 PM
To: "users@royale.apache.org<ma...@royale.apache.org>" <us...@royale.apache.org>>
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 <ca...@apache.org>> wrote:

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

2018-04-23 20:25 GMT+02:00 Harbs <ha...@gmail.com>>:
https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/DefaultShaper.js<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdevongovett%2Ffontkit%2Fblob%2Fmaster%2Fsrc%2Fopentype%2Fshapers%2FDefaultShaper.js&data=02%7C01%7Caharui%40adobe.com%7C4edbd2b558e74e9a2b2908d5a9590606%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636601122181399073&sdata=JSfSOlqmQljoqAcWYcTsSm9CtkhgKAUMKMekMeCIO7c%3D&reserved=0>
https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/UniversalShaper.js<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdevongovett%2Ffontkit%2Fblob%2Fmaster%2Fsrc%2Fopentype%2Fshapers%2FUniversalShaper.js&data=02%7C01%7Caharui%40adobe.com%7C4edbd2b558e74e9a2b2908d5a9590606%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636601122181399073&sdata=UTrg04irdAt0LvHn7nFpcpl8f0A76OSTDk3U3xTGMQw%3D&reserved=0>
https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/ArabicShaper.js<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdevongovett%2Ffontkit%2Fblob%2Fmaster%2Fsrc%2Fopentype%2Fshapers%2FArabicShaper.js&data=02%7C01%7Caharui%40adobe.com%7C4edbd2b558e74e9a2b2908d5a9590606%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636601122181399073&sdata=L8H2l079PzgcYRvgNYcQKVggrkRd%2BFXai%2F%2FB2jz1r%2Fs%3D&reserved=0>

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… ;-)

Harbs

On Apr 23, 2018, at 8:25 PM, Alex Harui <ah...@adobe.com>> wrote:

Harbs,

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.
https://www.bennadel.com/blog/3300-static-methods-are-inherited-when-using-es6-extends-syntax-in-javascript-and-node-js.htm<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.bennadel.com%2Fblog%2F3300-static-methods-are-inherited-when-using-es6-extends-syntax-in-javascript-and-node-js.htm&data=02%7C01%7Caharui%40adobe.com%7C4edbd2b558e74e9a2b2908d5a9590606%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636601122181399073&sdata=RVioofUKGF9BDNgtbLnViVWiI57ZP5p67%2F%2Bkd7X66eY%3D&reserved=0>

On 4/22/18, 11:46 PM, "Harbs" <ha...@gmail.com>> wrote:

   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.

   Harbs




--
Carlos Rovira
http://about.me/carlosrovira<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&data=02%7C01%7Caharui%40adobe.com%7C4edbd2b558e74e9a2b2908d5a9590606%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636601122181409081&sdata=ueDqpVran3kFnwhDVmvh1%2BU6oJdyOIiM60Jqr1GHI%2FA%3D&reserved=0>


Re: Static inheritance

Posted by Harbs <ha...@gmail.com>.
Not sure. Less boilerplate code?

> On Apr 24, 2018, at 9:41 AM, Alex Harui <ah...@adobe.com> wrote:
> 
> What are the advantages of static over the singleton pattern?
>  
> -Alex
>  
> From: Harbs <ha...@gmail.com>
> Reply-To: "users@royale.apache.org" <us...@royale.apache.org>
> Date: Monday, April 23, 2018 at 1:30 PM
> To: "users@royale.apache.org" <us...@royale.apache.org>
> 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 <carlosrovira@apache.org <ma...@apache.org>> wrote:
>>  
>> Ok, so that works in JS, but will work as well in SWF? 
>>  
>> 2018-04-23 20:25 GMT+02:00 Harbs <harbs.lists@gmail.com <ma...@gmail.com>>:
>>> https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/DefaultShaper.js <https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdevongovett%2Ffontkit%2Fblob%2Fmaster%2Fsrc%2Fopentype%2Fshapers%2FDefaultShaper.js&data=02%7C01%7Caharui%40adobe.com%7C4edbd2b558e74e9a2b2908d5a9590606%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636601122181399073&sdata=JSfSOlqmQljoqAcWYcTsSm9CtkhgKAUMKMekMeCIO7c%3D&reserved=0>
>>> https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/UniversalShaper.js <https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdevongovett%2Ffontkit%2Fblob%2Fmaster%2Fsrc%2Fopentype%2Fshapers%2FUniversalShaper.js&data=02%7C01%7Caharui%40adobe.com%7C4edbd2b558e74e9a2b2908d5a9590606%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636601122181399073&sdata=UTrg04irdAt0LvHn7nFpcpl8f0A76OSTDk3U3xTGMQw%3D&reserved=0>
>>> https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/ArabicShaper.js <https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdevongovett%2Ffontkit%2Fblob%2Fmaster%2Fsrc%2Fopentype%2Fshapers%2FArabicShaper.js&data=02%7C01%7Caharui%40adobe.com%7C4edbd2b558e74e9a2b2908d5a9590606%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636601122181399073&sdata=L8H2l079PzgcYRvgNYcQKVggrkRd%2BFXai%2F%2FB2jz1r%2Fs%3D&reserved=0>
>>>  
>>> 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… ;-)
>>>  
>>> Harbs
>>>  
>>>> On Apr 23, 2018, at 8:25 PM, Alex Harui <aharui@adobe.com <ma...@adobe.com>> wrote:
>>>>  
>>>> Harbs,
>>>> 
>>>> 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.
>>>> https://www.bennadel.com/blog/3300-static-methods-are-inherited-when-using-es6-extends-syntax-in-javascript-and-node-js.htm <https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.bennadel.com%2Fblog%2F3300-static-methods-are-inherited-when-using-es6-extends-syntax-in-javascript-and-node-js.htm&data=02%7C01%7Caharui%40adobe.com%7C4edbd2b558e74e9a2b2908d5a9590606%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636601122181399073&sdata=RVioofUKGF9BDNgtbLnViVWiI57ZP5p67%2F%2Bkd7X66eY%3D&reserved=0>
>>>> 
>>>> On 4/22/18, 11:46 PM, "Harbs" <harbs.lists@gmail.com <ma...@gmail.com>> wrote:
>>>> 
>>>>    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.
>>>> 
>>>>    Harbs
>>>> 
>>> 
>>>  
>> 
>> 
>> 
>>  
>> -- 
>> Carlos Rovira
>> http://about.me/carlosrovira <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&data=02%7C01%7Caharui%40adobe.com%7C4edbd2b558e74e9a2b2908d5a9590606%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636601122181409081&sdata=ueDqpVran3kFnwhDVmvh1%2BU6oJdyOIiM60Jqr1GHI%2FA%3D&reserved=0>

Re: Static inheritance

Posted by Alex Harui <ah...@adobe.com>.
What are the advantages of static over the singleton pattern?

-Alex

From: Harbs <ha...@gmail.com>
Reply-To: "users@royale.apache.org" <us...@royale.apache.org>
Date: Monday, April 23, 2018 at 1:30 PM
To: "users@royale.apache.org" <us...@royale.apache.org>
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 <ca...@apache.org>> wrote:

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

2018-04-23 20:25 GMT+02:00 Harbs <ha...@gmail.com>>:
https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/DefaultShaper.js<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdevongovett%2Ffontkit%2Fblob%2Fmaster%2Fsrc%2Fopentype%2Fshapers%2FDefaultShaper.js&data=02%7C01%7Caharui%40adobe.com%7C4edbd2b558e74e9a2b2908d5a9590606%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636601122181399073&sdata=JSfSOlqmQljoqAcWYcTsSm9CtkhgKAUMKMekMeCIO7c%3D&reserved=0>
https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/UniversalShaper.js<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdevongovett%2Ffontkit%2Fblob%2Fmaster%2Fsrc%2Fopentype%2Fshapers%2FUniversalShaper.js&data=02%7C01%7Caharui%40adobe.com%7C4edbd2b558e74e9a2b2908d5a9590606%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636601122181399073&sdata=UTrg04irdAt0LvHn7nFpcpl8f0A76OSTDk3U3xTGMQw%3D&reserved=0>
https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/ArabicShaper.js<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdevongovett%2Ffontkit%2Fblob%2Fmaster%2Fsrc%2Fopentype%2Fshapers%2FArabicShaper.js&data=02%7C01%7Caharui%40adobe.com%7C4edbd2b558e74e9a2b2908d5a9590606%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636601122181399073&sdata=L8H2l079PzgcYRvgNYcQKVggrkRd%2BFXai%2F%2FB2jz1r%2Fs%3D&reserved=0>

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… ;-)

Harbs

On Apr 23, 2018, at 8:25 PM, Alex Harui <ah...@adobe.com>> wrote:

Harbs,

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.
https://www.bennadel.com/blog/3300-static-methods-are-inherited-when-using-es6-extends-syntax-in-javascript-and-node-js.htm<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.bennadel.com%2Fblog%2F3300-static-methods-are-inherited-when-using-es6-extends-syntax-in-javascript-and-node-js.htm&data=02%7C01%7Caharui%40adobe.com%7C4edbd2b558e74e9a2b2908d5a9590606%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636601122181399073&sdata=RVioofUKGF9BDNgtbLnViVWiI57ZP5p67%2F%2Bkd7X66eY%3D&reserved=0>

On 4/22/18, 11:46 PM, "Harbs" <ha...@gmail.com>> wrote:

   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.

   Harbs




--
Carlos Rovira
http://about.me/carlosrovira<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&data=02%7C01%7Caharui%40adobe.com%7C4edbd2b558e74e9a2b2908d5a9590606%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636601122181409081&sdata=ueDqpVran3kFnwhDVmvh1%2BU6oJdyOIiM60Jqr1GHI%2FA%3D&reserved=0>



Re: Static inheritance

Posted by Harbs <ha...@gmail.com>.
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 <ca...@apache.org> wrote:
> 
> Ok, so that works in JS, but will work as well in SWF? 
> 
> 2018-04-23 20:25 GMT+02:00 Harbs <harbs.lists@gmail.com <ma...@gmail.com>>:
> https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/DefaultShaper.js <https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/DefaultShaper.js>
> https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/UniversalShaper.js <https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/UniversalShaper.js>
> https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/ArabicShaper.js <https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/ArabicShaper.js>
> 
> 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… ;-)
> 
> Harbs
> 
>> On Apr 23, 2018, at 8:25 PM, Alex Harui <aharui@adobe.com <ma...@adobe.com>> wrote:
>> 
>> Harbs,
>> 
>> 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.
>> https://www.bennadel.com/blog/3300-static-methods-are-inherited-when-using-es6-extends-syntax-in-javascript-and-node-js.htm <https://www.bennadel.com/blog/3300-static-methods-are-inherited-when-using-es6-extends-syntax-in-javascript-and-node-js.htm>
>> 
>> On 4/22/18, 11:46 PM, "Harbs" <harbs.lists@gmail.com <ma...@gmail.com>> wrote:
>> 
>>    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.
>> 
>>    Harbs
>> 
> 
> 
> 
> 
> -- 
> Carlos Rovira
> http://about.me/carlosrovira <http://about.me/carlosrovira>
> 


Re: Static inheritance

Posted by Carlos Rovira <ca...@apache.org>.
Ok, so that works in JS, but will work as well in SWF?

2018-04-23 20:25 GMT+02:00 Harbs <ha...@gmail.com>:

> https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/
> DefaultShaper.js
> https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/
> UniversalShaper.js
> https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/
> ArabicShaper.js
>
> 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… ;-)
>
> Harbs
>
> On Apr 23, 2018, at 8:25 PM, Alex Harui <ah...@adobe.com> wrote:
>
> Harbs,
>
> 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.
> https://www.bennadel.com/blog/3300-static-methods-are-
> inherited-when-using-es6-extends-syntax-in-javascript-and-node-js.htm
>
> On 4/22/18, 11:46 PM, "Harbs" <ha...@gmail.com> wrote:
>
>    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.
>
>    Harbs
>
>
>


-- 
Carlos Rovira
http://about.me/carlosrovira

Re: Static inheritance

Posted by Harbs <ha...@gmail.com>.
https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/DefaultShaper.js <https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/DefaultShaper.js>
https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/UniversalShaper.js <https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/UniversalShaper.js>
https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/ArabicShaper.js <https://github.com/devongovett/fontkit/blob/master/src/opentype/shapers/ArabicShaper.js>

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… ;-)

Harbs

> On Apr 23, 2018, at 8:25 PM, Alex Harui <ah...@adobe.com> wrote:
> 
> Harbs,
> 
> 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.
> https://www.bennadel.com/blog/3300-static-methods-are-inherited-when-using-es6-extends-syntax-in-javascript-and-node-js.htm
> 
> On 4/22/18, 11:46 PM, "Harbs" <ha...@gmail.com> wrote:
> 
>    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.
> 
>    Harbs
> 


Re: Static inheritance

Posted by Carlos Rovira <ca...@apache.org>.
Hi,

I'm interested in know what static inheritance will give us. I search a
bit, but couldn't see links that give some points about what this feature
will give us.

thanks



2018-04-23 19:25 GMT+02:00 Alex Harui <ah...@adobe.com>:

> Harbs,
>
> 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.
> https://www.bennadel.com/blog/3300-static-methods-are-
> inherited-when-using-es6-extends-syntax-in-javascript-and-node-js.htm
>
> On 4/22/18, 11:46 PM, "Harbs" <ha...@gmail.com> wrote:
>
>     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.
>
>     Harbs
>
>


-- 
Carlos Rovira
http://about.me/carlosrovira

Re: Static inheritance

Posted by Alex Harui <ah...@adobe.com>.
Harbs,

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.
https://www.bennadel.com/blog/3300-static-methods-are-inherited-when-using-es6-extends-syntax-in-javascript-and-node-js.htm

On 4/22/18, 11:46 PM, "Harbs" <ha...@gmail.com> wrote:

    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.
    
    Harbs