Ah yes, Class is currently in missing.js in typedefs because so far nobody 
needed it at runtime.

I kind of wish we could avoid creating a dummy Class and having it linked into 
every app via Language.is even thought it will only be around 20 bytes.
We could require a bead that injects the definition so folks can opt-in as 
needed.
We could have a plugin-scheme in Language-is so you can mixin more tests if you 
need it.  Right now it tests for Array which might be just-in-case code.

Thoughts?
-Alex

On 10/6/18, 9:51 AM, "Carlos Rovira" <[email protected]> wrote:

    Hi Piotr,
    
    I think the problem is more about what to do with "Class" since is valid in
    AS3 and we need proper transpiler to SWF, JS...
    Right now in JS Class is not know
    
    [Error] ReferenceError: Can't find variable: Class=
    
    As I posted in the first email, I can workaround with
    
    typeof myFunc === 'function'
    
    I think this could work for both cases, or maybe the solution you posted (I
    didn't try it)
    
    But the use case comes from trying to compile an existing Flex AS3 library
    with Royale, so we'll find "Class" keyword many times out there, so I think
    is worth it trying to solve at compiler/Language level.
    
    Thanks Piotr for the suggestion
    
    Carlos
    
    
    
    El sáb., 6 oct. 2018 a las 15:49, Piotr Zarzycki 
(<[email protected]>)
    escribió:
    
    > In the other words you are interested whether there is an object not a
    > simple type? That's what I mean.
    >
    > Why not if (are[0] is object) - does it not cover all of the cases?
    >
    >
    > On Sat, Oct 6, 2018, 2:48 PM Carlos Rovira <[email protected]>
    > wrote:
    >
    > > No, arr[0] has an instance of a custom typed object.
    > >
    > > El sáb., 6 oct. 2018 a las 10:58, Piotr Zarzycki (<
    > > [email protected]>)
    > > escribió:
    > >
    > > > Hi Carlos,
    > > >
    > > > Are you trying to distinguish something from simple type by that
    > > if(arr[0]
    > > > is Class) ? By simple type I mean String, Boolean?
    > > >
    > > > Piotr
    > > >
    > > > On Sat, Oct 6, 2018, 10:54 AM Carlos Rovira <[email protected]>
    > > > wrote:
    > > >
    > > > > Hi Alex,
    > > > >
    > > > > I'm very new to Language.as, so I'll try to do my best.
    > > > >
    > > > > I'm trying to add to Language.as "is" function this:
    > > > >
    > > > > if(rightOperand === Class) {
    > > > >                 return typeof leftOperand === 'function';
    > > > >             }
    > > > >
    > > > > the test case is :
    > > > >
    > > > > var arr:Array = [main]; //main is a container declared in MXML, so 
is
    > > not
    > > > > class is an instance
    > > > > if(arr[0] is Class)
    > > > > {
    > > > > trace("is Class");
    > > > > } else
    > > > > {
    > > > > trace("is NOT Class"); // I expect to get this trace
    > > > > }
    > > > >
    > > > > but browser reports:
    > > > >
    > > > > [Error] ReferenceError: Can't find variable: Class is
    > (Language.js:147)
    > > > >
    > > > > So first point to solve is how to deal with "Class", since is not
    > > > > recognized at javascript level. Seems to me that "Class" should be
    > > solved
    > > > > at compiler level?
    > > > >
    > > > > Thanks
    > > > >
    > > > >
    > > > > El vie., 5 oct. 2018 a las 23:11, Alex Harui
    > (<[email protected]
    > > > >)
    > > > > escribió:
    > > > >
    > > > > > Hi Carlos,
    > > > > >
    > > > > > Use of "is" is transpiled into a call to Language.is.  I think
    > > > > Language.is
    > > > > > should special case the test for Class.  Try updating Language.is
    > and
    > > > see
    > > > > > if that is what you need.
    > > > > >
    > > > > > -Alex
    > > > > >
    > > > > > On 10/5/18, 11:13 AM, "Carlos Rovira" <[email protected]>
    > > > wrote:
    > > > > >
    > > > > >     Hi,
    > > > > >
    > > > > >     in js, check if something is a class or is an instance is like
    > > this
    > > > > [1]
    > > > > >
    > > > > >     typeof myFunc === 'function'
    > > > > >
    > > > > >     In Royale since we are using AS3, doing
    > > > > >
    > > > > >     if(something is Class)
    > > > > >         do this
    > > > > >     else
    > > > > >        do that
    > > > > >
    > > > > >     should work either for SWF and for JS, but seems is not the
    > case.
    > > > > >     I must make two codes COMPILE::SWF (with "is Class") and
    > > > COMPILE::JS
    > > > > > (with
    > > > > >     typeof ... ==='function')
    > > > > >
    > > > > >     Could we have this abstracted by compiler?
    > > > > >
    > > > > >     Thanks
    > > > > >
    > > > > >     [1]
    > > > > >
    > > > > >
    > > > >
    > > >
    > >
    > 
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F405164%2Fbest-method-of-testing-for-a-function-in-javascript&amp;data=02%7C01%7Caharui%40adobe.com%7Cc7db54e53e2f46a7432c08d62babed31%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636744414790781943&amp;sdata=2KNNPEaX%2FIZKqlka8uMpiawbfAQDiRSi99nCnMU64eU%3D&amp;reserved=0
    > > > > >
    > > > > >     --
    > > > > >     Carlos Rovira
    > > > > >
    > > > > >
    > > > >
    > > >
    > >
    > 
https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&amp;data=02%7C01%7Caharui%40adobe.com%7Cc7db54e53e2f46a7432c08d62babed31%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636744414790781943&amp;sdata=O3UVXDCt36ga%2Ft9PXPcgQgqykthyeof%2Btrg%2Fu4QHeoU%3D&amp;reserved=0
    > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > > --
    > > > > Carlos Rovira
    > > > > 
https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&amp;data=02%7C01%7Caharui%40adobe.com%7Cc7db54e53e2f46a7432c08d62babed31%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636744414790781943&amp;sdata=O3UVXDCt36ga%2Ft9PXPcgQgqykthyeof%2Btrg%2Fu4QHeoU%3D&amp;reserved=0
    > > > >
    > > >
    > >
    > >
    > > --
    > > Carlos Rovira
    > > 
https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&amp;data=02%7C01%7Caharui%40adobe.com%7Cc7db54e53e2f46a7432c08d62babed31%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636744414790781943&amp;sdata=O3UVXDCt36ga%2Ft9PXPcgQgqykthyeof%2Btrg%2Fu4QHeoU%3D&amp;reserved=0
    > >
    >
    
    
    -- 
    Carlos Rovira
    
https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&amp;data=02%7C01%7Caharui%40adobe.com%7Cc7db54e53e2f46a7432c08d62babed31%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636744414790781943&amp;sdata=O3UVXDCt36ga%2Ft9PXPcgQgqykthyeof%2Btrg%2Fu4QHeoU%3D&amp;reserved=0
    

Reply via email to