This is just a warning, not an error. In flex-config.xml you can turn off any 
warning that you don't like.
 
I believe the ECMA committee is considering adding "let" for defining 
block-scoped vars:
 
if (flag)
{
    let x:Number = 3;
}
else
{
    let x:Number = 4;
}
 
- Gordon

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of 
sbyrne_dorado
Sent: Thursday, January 11, 2007 5:21 AM
To: [email protected]
Subject: [flexcoders] Re: Lexical scoping of variable declarations not working?



Ugh. I was hoping you were kidding, but it sounds like a dreadful
oversight (and, knowing one of the main authors of the ECMA standard,
a truly wizardly experienced guy, SHOCKING -- bad Quux, bad!). 

Down the road. Bah! [skipping snarky comments about language design
here]. I guess we'll have to contort our 2400+ class application to
deal with this silliness. Sigh.

Thanks Michael for your response!!!

--- In [email protected] <mailto:flexcoders%40yahoogroups.com> , 
"Michael Schmalle"
<[EMAIL PROTECTED]> wrote:
>
> This has been brought up and it's going to be fixed down the road
with ECMA.
> 
> Search the archives for Gordon's response. You won't be able to use var,
> it's some other weird keyword, I can't remember.
> 
> Peace, Mike
> 
> On 1/11/07, Jason Hawryluk <[EMAIL PROTECTED]> wrote:
> >
> > kind of like you can't do this
> >
> >
> >
> > public function clearTargetData(x:string):void{}
> >
> > public function clearTargetData():void{}
> >
> >
> > which most support also, but I give Adobe the benefit of the doubt
this is
> > a completely new flex, built from the ground up, and they have
done a bang
> > up job.
> >
> > I can do with out these things, perhaps they'll implement this type of
> > stuff in a later version.
> >
> > jason
> >
> >
> >
> >
> > -----Message d'origine-----
> > *De :* [email protected] <mailto:flexcoders%40yahoogroups.com> 
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com> ]*De
> > la part de* sbyrne_dorado
> > *Envoyé :* jeudi 11 janvier 2007 10:09
> > *À :* [email protected] <mailto:flexcoders%40yahoogroups.com> 
> > *Objet :* [flexcoders] Lexical scoping of variable declarations not
> > working?
> >
> > I'm seeing some odd behavior with the AS3 compiler. I say it's "odd"
> > because it's at variance with the vast majority of C language
> > derivatives (in fact, I'll go out on a limb and say ALL of them). The
> > behavior I'm seeing is this:
> >
> > If I have
> >
> > package {
> > public class badscope {
> >
> > public function dummy() : void {
> > if (new Date() != null) {
> > var foo : Number = 3;
> > } else {
> > var foo : Number = 4;
> > }
> > }
> >
> > }
> > }
> >
> > the cmopiler is telling me that "foo" is a duplicate declaration. Um.
> > Every other block structured language I'm familiar with scopes local
> > variable declaration to the enclosing block, so the foo's do not exist
> > in the same lexical scope and there is no conflict. To me, if this
> > behavior of placing all variable declarations in the top level
> > function's scope is in fact the desired behavior, it's a HUGE step
> > backwards.
> >
> > Please help me to understand why I'm seeing the behavior I am, and why
> > it's not breaking lexical scoping rules common to C derivatives.
> >
> > 
> >
> 
> 
> 
> -- 
> Teoti Graphix
> http://www.teotigraphix.com <http://www.teotigraphix.com> 
> 
> Blog - Flex2Components
> http://www.flex2components.com <http://www.flex2components.com> 
> 
> You can find more by solving the problem then by 'asking the question'.
>



 

Reply via email to