[Flashcoders] compiler not warning (little rant)

2006-03-01 Thread Michael Stuhr

A/MMC does not warn before using this:

var o = new Object();
o.arguments  [1, 2, 3];

is this a statement or what ? and if so, what does it do, all i could see is 
undefined / null / not there



fun to find this one in a ~1 lines project.


micha
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] compiler not warning (little rant)

2006-03-01 Thread David Rorex
On 3/1/06, Michael Stuhr [EMAIL PROTECTED] wrote:
 A/MMC does not warn before using this:

 var o = new Object();
 o.arguments  [1, 2, 3];

 is this a statement or what ? and if so, what does it do, all i could see is
 undefined / null / not there


 fun to find this one in a ~1 lines project.



So...technically that is legal, though I don't know why anyone would do that.

First of all, you can put a constant on a line by itself, and it just
does nothing:

3; // this is legal in AS
myObj.blah[3] // this is also legal

Secondly, there is the syntax ([expr1],[expr2],...,[exprN]), which
will execute all the expressions, and return the result of exprN.
so:
 (1,2,3)

is the same as:

function blah()
{
   1; // legal, as per above.
   2;
   return 3;
}
blah();


Finally, your statement combines the two principles:
o.arguments[1,2,3];
is the same as :
o.arguments[ (1,2,3) ];

compiles to:

1;
2;
o.arguments[3];

which are 3 legal commands, but they don't do anything.

Hope this helps your understanding a bit. But I agree, MMC should
definately have a 'strict compile' mode that warns when you do weird
things like that. AS3 probably would complain (maybe not though?)

-David R
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] compiler not warning (little rant)

2006-03-01 Thread Michael Stuhr

David Rorex schrieb:

On 3/1/06, Michael Stuhr [EMAIL PROTECTED] wrote:
  

A/MMC does not warn before using this:

var o = new Object();
o.arguments  [1, 2, 3];

is this a statement or what ? and if so, what does it do, all i could see is
undefined / null / not there


fun to find this one in a ~1 lines project.





So...technically that is legal, though I don't know why anyone would do that.

First of all, you can put a constant on a line by itself, and it just
does nothing:

3; // this is legal in AS
myObj.blah[3] // this is also legal

Secondly, there is the syntax ([expr1],[expr2],...,[exprN]), which
will execute all the expressions, and return the result of exprN.
so:
 (1,2,3)

is the same as:

function blah()
{
   1; // legal, as per above.
   2;
   return 3;
}
blah();


Finally, your statement combines the two principles:
o.arguments[1,2,3];
is the same as :
o.arguments[ (1,2,3) ];

compiles to:

1;
2;
o.arguments[3];

which are 3 legal commands, but they don't do anything.

Hope this helps your understanding a bit. But I agree, MMC should
definately have a 'strict compile' mode that warns when you do weird
things like that. AS3 probably would complain (maybe not though?)

-David R
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

  

thanks  for your time, but that doesn't answer my q's. i had:

o.arguments  [1, 2, 3];
with whitespace in there, where there should be a 
'='
so why doesn't MMC complpain about that ? i this a legal statement ? 
i know  
'o.arguments[1, 2, 3];'

or equivalent would be, but i didn't write that.

micha




___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] compiler not warning (little rant)

2006-03-01 Thread Martin Wood
so why doesn't MMC complpain about that ? i this a legal statement ? i 
know  'o.arguments[1, 2, 3];'

or equivalent would be, but i didn't write that.


as far as the compiler is concerned you did write that because whitespace is 
ignored. e.g.


: code :

var x:Array = [];

x [   0 ]  =  23;

trace  (  x   [0  ]  )  ;

: output :

23

:)

martin

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com