On Thu, Feb 21, 2008 at 6:23 PM, Kevin Brown <[EMAIL PROTECTED]> wrote:

> On Thu, Feb 21, 2008 at 6:03 PM, Paul Lindner <[EMAIL PROTECTED]> wrote:
>
> > Here's what's going on:
> >
> >
> > YUI Compressor 2.3.5, 2008-02-08
> > --------------------------------
> >
> > + Added a warning when more than one 'var' statement is used in a single
> > scope.
> >  Automatic coalescence is extremely complicated, and would be unsafe if
> > not
> >  done properly.
> >
> >
> > At first I thought it was bogus, but it turns out it's correct.  Try
> > running this code and guess what the output is:
> >
> >  for (var i=0; i< 10; i++) {
> >    document.write(i + " ");
> >    document.write(" ");
> >  }
> >  document.write("<br>result is " + i);
> >
> > 1 2 3 4 5 6 7 8 9
> > result is 10
> >
> >
> > Digging deeper I find that javascript's local scope is only local to
> > the function.  ... shudder ....
>
>
> Not quite; it doesn't have a "local" scope, it only has closure scope (and
> a
> function produces a closure). Javascript does not support anonymous scopes
> as seen in languages such as java and C++ (what you're really doing when
> you
> put brackets after a control statement). This is the same as in C and most
> functional programming languages.
>
> That being said, I disagree with the YUI compressor comment's assertion
> that
> it's difficult, because there are at least two minifiers that I've used
> that
> do it without issue (unfortunately, we can't use them on this project).
> I'd
> love to see support for this added anyway though, as it's also got
> performance benefits.


I'll +1 this. Also, if we can't use more than one var in a scope when
coding, our js code is going to look ridiculously ugly. Better to just get a
robust compiler in here to do a better job.



>
>
>
> >
> >
> > On Thu, Feb 21, 2008 at 05:30:02PM -0800, Cassie wrote:
> > > When running the shindig server these days we are now getting tons and
> > tons
> > > of js warnings. It seems to be linting for some very weird things, the
> > most
> > > prevalent being "Try to use a single 'var' statement per scope."
> > >
> > > Does anyone know how to turn off this particular warning? I don't
> think
> > it
> > > is useful at all (using more than one var per scope in js is perfectly
> > > reasonable) and is hiding some of the hopefully more valuable
> warnings.
> > >
> > > Thanks!
> > >
> > > - Cassie
> >
> > --
> > Paul Lindner
> > hi5 Architect
> > [EMAIL PROTECTED]
> >
>
>
>
> --
> ~Kevin
>
> If you received this email by mistake, please delete it, cancel your mail
> account, destroy your hard drive, silence any witnesses, and burn down the
> building that you're in.
>

Reply via email to