You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Maria Jose Esteve <mj...@iest.com> on 2024/12/10 21:59:11 UTC

The instanceof operator is deprecated

I'm finishing debugging warnings when compiling royale-asjs and I have another question with the “instanceof” statement.

The specific message is: “Use of the instanceof operator.  The instanceof operator is deprecated, use the is operator instead”

These messages only appear in the XML project and I don't know why. For example:
                if (xml1 instanceof XMLList) return XMLList.mixedEquality(xml1 as XMLList, other);
                                    ^
I understand that this instruction should be modified to:
if (xml1 is XMLList) return XMLList.mixedEquality(xml1 as XMLList, other);

But I want to understand why when compiling the Network project, the same warning is not shown in AMFContext.as (and in many other files)
Does anyone know? 😝

Hiedra


Re: The instanceof operator is deprecated

Posted by Greg Dove <gr...@gmail.com>.
Yes, these are all very likely explicit decisions.

There is a compiler flag "warn-instance-of-changes" to ignore this warning.
I have definitely had it in the back of my mind to switch this on for more
of the build stuff in the past where it was adding to build noise. Perhaps
there is a difference between ant and maven project configurations for this
as well....



On Wed, Dec 11, 2024 at 12:02 PM Maria Jose Esteve <mj...@iest.com>
wrote:

> You're right, I missed it.
> I'll check the sass build and I think we can call it done unless someone
> sees something else that I missed.
>
> Hiedra
>
> -----Mensaje original-----
> De: Josh Tynjala <jo...@bowlerhat.dev>
> Enviado el: martes, 10 de diciembre de 2024 23:57
> Para: dev@royale.apache.org
> Asunto: Re: The instanceof operator is deprecated
>
> The doc comment on the isFunctionValue() method in AMFContext.as talks
> about certain differences between using instanceof in JS and AS3 code. That
> makes me think that it should be left alone because it sounds like
> instanceof is being used on purpose.
>
> --
> Josh Tynjala
> Bowler Hat LLC <https://bowlerhat.dev>
>
>
> On Tue, Dec 10, 2024 at 2:42 PM Maria Jose Esteve <mj...@iest.com>
> wrote:
>
> > I suspected there was a good reason, so I asked. I seem to recall
> > reading Harb working with XML and it seemed strange to me that if this
> > was supposed to be replaced by "Is" he hadn't corrected it.
> > Ok, I don't touch " instanceof".
> >
> > Regarding AMFContext.as... I've checked my log file again (from the
> > SDK
> > compilation) and I don't see any other "instanceof" warnings BUT if I
> > open the isolated project in VSCode I do see it.
> > Maybe it's because I compile for OnlyJS.
> > Hahahaha, I didn't understand ANYTHING you explained to me about SWF
> > and playerglobal.swc.... but don't worry, I'm not going to ask you to
> > explain it to me 😝
> >
> > Do you think we should just leave this first debugging alone and
> > finish here?
> > Do you think I should change AMFContext.as because in this case it is
> > safe to change to IS?
> >
> > Hiedra
> >
> > -----Mensaje original-----
> > De: Josh Tynjala <jo...@bowlerhat.dev> Enviado el: martes, 10 de
> > diciembre de 2024 23:18
> > Para: dev@royale.apache.org
> > Asunto: Re: The instanceof operator is deprecated
> >
> > I don't know exactly why the developer who implemented the XML classes
> > chose instanceof instead of is, but I suspect that they did it on
> purpose.
> > While the instanceof operator is considered deprecated in AS3, and the
> > is operator is preferred, there may (very rarely) be legitimate
> > reasons to choose instanceof over is when AS3 is compiled to JS.
> >
> > One of those reasons could be performance. JS doesn't have an is
> operator.
> > So, we need to emulate its behavior from AS3 in Royale. However, if
> > we're sure that using native JS instanceof will be much faster, and
> > won't break anything, then it might make sense to make an exception to
> > the typical advice to prefer the is operator.
> >
> > For this reason, I would suggest that you avoid changing code in
> > royale-asjs that uses instanceof.
> >
> > I just opened the Network project, and I can see a warning for use of
> > instanceof in AMFContext.as. Perhaps you need to resolve another issue
> > in your local configuration before this warning will be displayed. For
> > example, I had to remove SWF from the targets because my current SDK
> > doesn't have playerglobal.swc.
> >
> > --
> > Josh Tynjala
> > Bowler Hat LLC <https://bowlerhat.dev>
> >
> >
> > On Tue, Dec 10, 2024 at 2:01 PM Maria Jose Esteve <mj...@iest.com>
> > wrote:
> >
> > > I'm finishing debugging warnings when compiling royale-asjs and I
> > > have another question with the “instanceof” statement.
> > >
> > > The specific message is: “Use of the instanceof operator.  The
> > > instanceof operator is deprecated, use the is operator instead”
> > >
> > > These messages only appear in the XML project and I don't know why.
> > > For
> > > example:
> > >                 if (xml1 instanceof XMLList) return
> > > XMLList.mixedEquality(xml1 as XMLList, other);
> > >                                     ^ I understand that this
> > > instruction should be modified to:
> > > if (xml1 is XMLList) return XMLList.mixedEquality(xml1 as XMLList,
> > > other);
> > >
> > > But I want to understand why when compiling the Network project, the
> > > same warning is not shown in AMFContext.as (and in many other files)
> > > Does anyone know? 😝
> > >
> > > Hiedra
> > >
> > >
> >
>

RE: The instanceof operator is deprecated

Posted by Maria Jose Esteve <mj...@iest.com>.
You're right, I missed it.
I'll check the sass build and I think we can call it done unless someone sees something else that I missed.

Hiedra

-----Mensaje original-----
De: Josh Tynjala <jo...@bowlerhat.dev> 
Enviado el: martes, 10 de diciembre de 2024 23:57
Para: dev@royale.apache.org
Asunto: Re: The instanceof operator is deprecated

The doc comment on the isFunctionValue() method in AMFContext.as talks about certain differences between using instanceof in JS and AS3 code. That makes me think that it should be left alone because it sounds like instanceof is being used on purpose.

--
Josh Tynjala
Bowler Hat LLC <https://bowlerhat.dev>


On Tue, Dec 10, 2024 at 2:42 PM Maria Jose Esteve <mj...@iest.com> wrote:

> I suspected there was a good reason, so I asked. I seem to recall 
> reading Harb working with XML and it seemed strange to me that if this 
> was supposed to be replaced by "Is" he hadn't corrected it.
> Ok, I don't touch " instanceof".
>
> Regarding AMFContext.as... I've checked my log file again (from the 
> SDK
> compilation) and I don't see any other "instanceof" warnings BUT if I 
> open the isolated project in VSCode I do see it.
> Maybe it's because I compile for OnlyJS.
> Hahahaha, I didn't understand ANYTHING you explained to me about SWF 
> and playerglobal.swc.... but don't worry, I'm not going to ask you to 
> explain it to me 😝
>
> Do you think we should just leave this first debugging alone and 
> finish here?
> Do you think I should change AMFContext.as because in this case it is 
> safe to change to IS?
>
> Hiedra
>
> -----Mensaje original-----
> De: Josh Tynjala <jo...@bowlerhat.dev> Enviado el: martes, 10 de 
> diciembre de 2024 23:18
> Para: dev@royale.apache.org
> Asunto: Re: The instanceof operator is deprecated
>
> I don't know exactly why the developer who implemented the XML classes 
> chose instanceof instead of is, but I suspect that they did it on purpose.
> While the instanceof operator is considered deprecated in AS3, and the 
> is operator is preferred, there may (very rarely) be legitimate 
> reasons to choose instanceof over is when AS3 is compiled to JS.
>
> One of those reasons could be performance. JS doesn't have an is operator.
> So, we need to emulate its behavior from AS3 in Royale. However, if 
> we're sure that using native JS instanceof will be much faster, and 
> won't break anything, then it might make sense to make an exception to 
> the typical advice to prefer the is operator.
>
> For this reason, I would suggest that you avoid changing code in 
> royale-asjs that uses instanceof.
>
> I just opened the Network project, and I can see a warning for use of 
> instanceof in AMFContext.as. Perhaps you need to resolve another issue 
> in your local configuration before this warning will be displayed. For 
> example, I had to remove SWF from the targets because my current SDK 
> doesn't have playerglobal.swc.
>
> --
> Josh Tynjala
> Bowler Hat LLC <https://bowlerhat.dev>
>
>
> On Tue, Dec 10, 2024 at 2:01 PM Maria Jose Esteve <mj...@iest.com>
> wrote:
>
> > I'm finishing debugging warnings when compiling royale-asjs and I 
> > have another question with the “instanceof” statement.
> >
> > The specific message is: “Use of the instanceof operator.  The 
> > instanceof operator is deprecated, use the is operator instead”
> >
> > These messages only appear in the XML project and I don't know why.
> > For
> > example:
> >                 if (xml1 instanceof XMLList) return
> > XMLList.mixedEquality(xml1 as XMLList, other);
> >                                     ^ I understand that this 
> > instruction should be modified to:
> > if (xml1 is XMLList) return XMLList.mixedEquality(xml1 as XMLList, 
> > other);
> >
> > But I want to understand why when compiling the Network project, the 
> > same warning is not shown in AMFContext.as (and in many other files) 
> > Does anyone know? 😝
> >
> > Hiedra
> >
> >
>

Re: The instanceof operator is deprecated

Posted by Josh Tynjala <jo...@bowlerhat.dev>.
The doc comment on the isFunctionValue() method in AMFContext.as talks
about certain differences between using instanceof in JS and AS3 code. That
makes me think that it should be left alone because it sounds like
instanceof is being used on purpose.

--
Josh Tynjala
Bowler Hat LLC <https://bowlerhat.dev>


On Tue, Dec 10, 2024 at 2:42 PM Maria Jose Esteve <mj...@iest.com> wrote:

> I suspected there was a good reason, so I asked. I seem to recall reading
> Harb working with XML and it seemed strange to me that if this was supposed
> to be replaced by "Is" he hadn't corrected it.
> Ok, I don't touch " instanceof".
>
> Regarding AMFContext.as... I've checked my log file again (from the SDK
> compilation) and I don't see any other "instanceof" warnings BUT if I open
> the isolated project in VSCode I do see it.
> Maybe it's because I compile for OnlyJS.
> Hahahaha, I didn't understand ANYTHING you explained to me about SWF and
> playerglobal.swc.... but don't worry, I'm not going to ask you to explain
> it to me 😝
>
> Do you think we should just leave this first debugging alone and finish
> here?
> Do you think I should change AMFContext.as because in this case it is safe
> to change to IS?
>
> Hiedra
>
> -----Mensaje original-----
> De: Josh Tynjala <jo...@bowlerhat.dev>
> Enviado el: martes, 10 de diciembre de 2024 23:18
> Para: dev@royale.apache.org
> Asunto: Re: The instanceof operator is deprecated
>
> I don't know exactly why the developer who implemented the XML classes
> chose instanceof instead of is, but I suspect that they did it on purpose.
> While the instanceof operator is considered deprecated in AS3, and the is
> operator is preferred, there may (very rarely) be legitimate reasons to
> choose instanceof over is when AS3 is compiled to JS.
>
> One of those reasons could be performance. JS doesn't have an is operator.
> So, we need to emulate its behavior from AS3 in Royale. However, if we're
> sure that using native JS instanceof will be much faster, and won't break
> anything, then it might make sense to make an exception to the typical
> advice to prefer the is operator.
>
> For this reason, I would suggest that you avoid changing code in
> royale-asjs that uses instanceof.
>
> I just opened the Network project, and I can see a warning for use of
> instanceof in AMFContext.as. Perhaps you need to resolve another issue in
> your local configuration before this warning will be displayed. For
> example, I had to remove SWF from the targets because my current SDK
> doesn't have playerglobal.swc.
>
> --
> Josh Tynjala
> Bowler Hat LLC <https://bowlerhat.dev>
>
>
> On Tue, Dec 10, 2024 at 2:01 PM Maria Jose Esteve <mj...@iest.com>
> wrote:
>
> > I'm finishing debugging warnings when compiling royale-asjs and I have
> > another question with the “instanceof” statement.
> >
> > The specific message is: “Use of the instanceof operator.  The
> > instanceof operator is deprecated, use the is operator instead”
> >
> > These messages only appear in the XML project and I don't know why.
> > For
> > example:
> >                 if (xml1 instanceof XMLList) return
> > XMLList.mixedEquality(xml1 as XMLList, other);
> >                                     ^
> > I understand that this instruction should be modified to:
> > if (xml1 is XMLList) return XMLList.mixedEquality(xml1 as XMLList,
> > other);
> >
> > But I want to understand why when compiling the Network project, the
> > same warning is not shown in AMFContext.as (and in many other files)
> > Does anyone know? 😝
> >
> > Hiedra
> >
> >
>

RE: The instanceof operator is deprecated

Posted by Maria Jose Esteve <mj...@iest.com>.
I suspected there was a good reason, so I asked. I seem to recall reading Harb working with XML and it seemed strange to me that if this was supposed to be replaced by "Is" he hadn't corrected it.
Ok, I don't touch " instanceof".

Regarding AMFContext.as... I've checked my log file again (from the SDK compilation) and I don't see any other "instanceof" warnings BUT if I open the isolated project in VSCode I do see it.
Maybe it's because I compile for OnlyJS.
Hahahaha, I didn't understand ANYTHING you explained to me about SWF and playerglobal.swc.... but don't worry, I'm not going to ask you to explain it to me 😝

Do you think we should just leave this first debugging alone and finish here?
Do you think I should change AMFContext.as because in this case it is safe to change to IS?

Hiedra

-----Mensaje original-----
De: Josh Tynjala <jo...@bowlerhat.dev> 
Enviado el: martes, 10 de diciembre de 2024 23:18
Para: dev@royale.apache.org
Asunto: Re: The instanceof operator is deprecated

I don't know exactly why the developer who implemented the XML classes chose instanceof instead of is, but I suspect that they did it on purpose.
While the instanceof operator is considered deprecated in AS3, and the is operator is preferred, there may (very rarely) be legitimate reasons to choose instanceof over is when AS3 is compiled to JS.

One of those reasons could be performance. JS doesn't have an is operator.
So, we need to emulate its behavior from AS3 in Royale. However, if we're sure that using native JS instanceof will be much faster, and won't break anything, then it might make sense to make an exception to the typical advice to prefer the is operator.

For this reason, I would suggest that you avoid changing code in royale-asjs that uses instanceof.

I just opened the Network project, and I can see a warning for use of instanceof in AMFContext.as. Perhaps you need to resolve another issue in your local configuration before this warning will be displayed. For example, I had to remove SWF from the targets because my current SDK doesn't have playerglobal.swc.

--
Josh Tynjala
Bowler Hat LLC <https://bowlerhat.dev>


On Tue, Dec 10, 2024 at 2:01 PM Maria Jose Esteve <mj...@iest.com> wrote:

> I'm finishing debugging warnings when compiling royale-asjs and I have 
> another question with the “instanceof” statement.
>
> The specific message is: “Use of the instanceof operator.  The 
> instanceof operator is deprecated, use the is operator instead”
>
> These messages only appear in the XML project and I don't know why. 
> For
> example:
>                 if (xml1 instanceof XMLList) return
> XMLList.mixedEquality(xml1 as XMLList, other);
>                                     ^
> I understand that this instruction should be modified to:
> if (xml1 is XMLList) return XMLList.mixedEquality(xml1 as XMLList, 
> other);
>
> But I want to understand why when compiling the Network project, the 
> same warning is not shown in AMFContext.as (and in many other files) 
> Does anyone know? 😝
>
> Hiedra
>
>

Re: The instanceof operator is deprecated

Posted by Harbs <ha...@gmail.com>.
That would be me.

Yes. It was on purpose, but it’s been so long ago that I don’t remember for sure why.

Harbs

> On Dec 11, 2024, at 12:18 AM, Josh Tynjala <jo...@bowlerhat.dev> wrote:
> 
> I don't know exactly why the developer who implemented the XML classes
> chose instanceof instead of is, but I suspect that they did it on purpose.


Re: The instanceof operator is deprecated

Posted by Josh Tynjala <jo...@bowlerhat.dev>.
I don't know exactly why the developer who implemented the XML classes
chose instanceof instead of is, but I suspect that they did it on purpose.
While the instanceof operator is considered deprecated in AS3, and the is
operator is preferred, there may (very rarely) be legitimate reasons to
choose instanceof over is when AS3 is compiled to JS.

One of those reasons could be performance. JS doesn't have an is operator.
So, we need to emulate its behavior from AS3 in Royale. However, if we're
sure that using native JS instanceof will be much faster, and won't break
anything, then it might make sense to make an exception to the typical
advice to prefer the is operator.

For this reason, I would suggest that you avoid changing code in
royale-asjs that uses instanceof.

I just opened the Network project, and I can see a warning for use of
instanceof in AMFContext.as. Perhaps you need to resolve another issue in
your local configuration before this warning will be displayed. For
example, I had to remove SWF from the targets because my current SDK
doesn't have playerglobal.swc.

--
Josh Tynjala
Bowler Hat LLC <https://bowlerhat.dev>


On Tue, Dec 10, 2024 at 2:01 PM Maria Jose Esteve <mj...@iest.com> wrote:

> I'm finishing debugging warnings when compiling royale-asjs and I have
> another question with the “instanceof” statement.
>
> The specific message is: “Use of the instanceof operator.  The instanceof
> operator is deprecated, use the is operator instead”
>
> These messages only appear in the XML project and I don't know why. For
> example:
>                 if (xml1 instanceof XMLList) return
> XMLList.mixedEquality(xml1 as XMLList, other);
>                                     ^
> I understand that this instruction should be modified to:
> if (xml1 is XMLList) return XMLList.mixedEquality(xml1 as XMLList, other);
>
> But I want to understand why when compiling the Network project, the same
> warning is not shown in AMFContext.as (and in many other files)
> Does anyone know? 😝
>
> Hiedra
>
>