You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Alex Harui <ah...@adobe.com> on 2016/08/22 05:38:16 UTC

[Falcon] Compatibility with MXMLC

Hi,

While debugging why some code in the MX/Spark for FlexJS wasn't working, I
saw something like this:

private function isVertical():Boolean
{
   ...
}

Public function measure():void
{
   var isVertical:Boolean = isVertical();
}

MXMLC seems to be ok with this.  For Falcon, the resolver finds the local
variable (which I think it should) and generates a call to that local
variable which isn't even of type Function, and an exception is thrown at
runtime.  No compiler error is reported.

MXMLC not only doesn't generate an error, it seems to generate a function
call to isVertical() by getting the instance "isVertical".  IOW, MXMLC
seems to think the above code is equivalent to:

public function measure():void
{
    var isVertical:Boolean = this.isVertical();
}

It seems to me that Falcon is correct.  AIUI, local variables should mask
instance variables and require you to use "this." to access the instance
version.


So the questions are:
-Should Falcon add logic to resolve "isVertical" to the instance function
in order to be backward-compatible with MXMLC?
-Should Falcon generate an error if there is an attempt to make a function
call on a variable that isn't of type Function, Object or *?
-Should I fix the code in the SDK to add "this." to isVertical()?
-is there supposed to be an exception in resolving for Function calls?

Thanks,
-Alex


Re: [Falcon] Compatibility with MXMLC

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

On 8/22/16, 8:05 AM, "Josh Tynjala" <jo...@gmail.com> wrote:

>1. No. The "this." should definitely be required in this case. The older
>compiler was wrong, and we should not continue to propagate the bug. Most
>likely, ASC 2.0 in the Adobe AIR SDK behaves the same as Falcon, so it
>would be good if that particular code were treated the same in all modern
>ActionScript compilers.

Well, we had one opinion for the opposite.  I think I might leverage the
-compiler.mxml.compatibility-version option.  Even though this isn't MXML,
we'll add a 4.7 version as the default and require 'this'.  But if you set
compatibility-version to 4.6 or earlier you will get legacy behavior.


>4. If you call something that is not a function, Flash Player will throw
>an
>exception.

Actually, what I meant was, has anyone seen mention of a specification
where resolving functions is different from resolving variables such that
'this' isn't actually required?

Thanks,
-Alex


Re: [Falcon] Compatibility with MXMLC

Posted by Josh Tynjala <jo...@gmail.com>.
1. No. The "this." should definitely be required in this case. The older
compiler was wrong, and we should not continue to propagate the bug. Most
likely, ASC 2.0 in the Adobe AIR SDK behaves the same as Falcon, so it
would be good if that particular code were treated the same in all modern
ActionScript compilers.

2. Yes, I think an error is a good idea. You might also need to allow Class
to be allowed in function calls too. I believe "new Example()" is
considered a function call. There's a property that says if the function
call includes "new". Casting might be considered a function call too. I
don't remember.

3. It's probably a good idea. It won't hurt anything, and it will improve
compatibility.

4. If you call something that is not a function, Flash Player will throw an
exception.

TypeError: Error #1006: value is not a function.

- Josh

On Sun, Aug 21, 2016 at 10:38 PM, Alex Harui <ah...@adobe.com> wrote:

> Hi,
>
> While debugging why some code in the MX/Spark for FlexJS wasn't working, I
> saw something like this:
>
> private function isVertical():Boolean
> {
>    ...
> }
>
> Public function measure():void
> {
>    var isVertical:Boolean = isVertical();
> }
>
> MXMLC seems to be ok with this.  For Falcon, the resolver finds the local
> variable (which I think it should) and generates a call to that local
> variable which isn't even of type Function, and an exception is thrown at
> runtime.  No compiler error is reported.
>
> MXMLC not only doesn't generate an error, it seems to generate a function
> call to isVertical() by getting the instance "isVertical".  IOW, MXMLC
> seems to think the above code is equivalent to:
>
> public function measure():void
> {
>     var isVertical:Boolean = this.isVertical();
> }
>
> It seems to me that Falcon is correct.  AIUI, local variables should mask
> instance variables and require you to use "this." to access the instance
> version.
>
>
> So the questions are:
> -Should Falcon add logic to resolve "isVertical" to the instance function
> in order to be backward-compatible with MXMLC?
> -Should Falcon generate an error if there is an attempt to make a function
> call on a variable that isn't of type Function, Object or *?
> -Should I fix the code in the SDK to add "this." to isVertical()?
> -is there supposed to be an exception in resolving for Function calls?
>
> Thanks,
> -Alex
>
>

Re: [Falcon] Compatibility with MXMLC

Posted by Fréderic Cox <co...@gmail.com>.
For me falcon should add logic to resolve "isVertical" to the instance
function
in order to be backward-compatible with MXMLC as this. is omitted a lot in
AS3 code currently.
This would be a lot to fix if all the projects throw an error where code
like this is used.

On Mon, Aug 22, 2016 at 7:38 AM, Alex Harui <ah...@adobe.com> wrote:

> Hi,
>
> While debugging why some code in the MX/Spark for FlexJS wasn't working, I
> saw something like this:
>
> private function isVertical():Boolean
> {
>    ...
> }
>
> Public function measure():void
> {
>    var isVertical:Boolean = isVertical();
> }
>
> MXMLC seems to be ok with this.  For Falcon, the resolver finds the local
> variable (which I think it should) and generates a call to that local
> variable which isn't even of type Function, and an exception is thrown at
> runtime.  No compiler error is reported.
>
> MXMLC not only doesn't generate an error, it seems to generate a function
> call to isVertical() by getting the instance "isVertical".  IOW, MXMLC
> seems to think the above code is equivalent to:
>
> public function measure():void
> {
>     var isVertical:Boolean = this.isVertical();
> }
>
> It seems to me that Falcon is correct.  AIUI, local variables should mask
> instance variables and require you to use "this." to access the instance
> version.
>
>
> So the questions are:
> -Should Falcon add logic to resolve "isVertical" to the instance function
> in order to be backward-compatible with MXMLC?
> -Should Falcon generate an error if there is an attempt to make a function
> call on a variable that isn't of type Function, Object or *?
> -Should I fix the code in the SDK to add "this." to isVertical()?
> -is there supposed to be an exception in resolving for Function calls?
>
> Thanks,
> -Alex
>
>