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 (<piotrzarzyck...@gmail.com>)
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 <carlosrov...@apache.org>
> wrote:
>
> > No, arr[0] has an instance of a custom typed object.
> >
> > El sáb., 6 oct. 2018 a las 10:58, Piotr Zarzycki (<
> > piotrzarzyck...@gmail.com>)
> > 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 <carlosrov...@apache.org>
> > > 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
> (<aha...@adobe.com.invalid
> > > >)
> > > > 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" <carlosrov...@apache.org>
> > > 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%7Ca4d898cf20fe4f072a9008d62aee4d24%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636743600312034959&amp;sdata=fdiolpGWQJihoZw2PfYLmoyckh1mDiynH8EbJXYIeog%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%7Ca4d898cf20fe4f072a9008d62aee4d24%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636743600312034959&amp;sdata=bwLXrUQ6N4syATPB8iEXL%2BnFZPQl9xhIndqwNbCShCo%3D&amp;reserved=0
> > > > >
> > > > >
> > > > >
> > > >
> > > > --
> > > > Carlos Rovira
> > > > http://about.me/carlosrovira
> > > >
> > >
> >
> >
> > --
> > Carlos Rovira
> > http://about.me/carlosrovira
> >
>


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

Reply via email to