On Thu, Nov 11, 2010 at 5:10 PM, Allen Wirfs-Brock <
allen.wirfs-br...@microsoft.com> wrote:

> I believe that would be interoperable as long as each such function is only
> declared and used within a single block.  Multiple declarations with the
> same function name in separate blocks wouldn't be interoperable among all
> browsers.
>

Not quite. It will be incompatible with ES5/strict on those ES5
implementations that follow <
http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls
>.

For the example code you show under the assumptions you state, if you move
the function declaration into the top level of the containing function or
program, then it will be compat with ES5/strict best practice as well, and
still with everything else.



>
> Allen
>
> > -----Original Message-----
> > From: Michael Day [mailto:mike...@yeslogic.com]
> > Sent: Thursday, November 11, 2010 4:48 PM
> > To: Brendan Eich
> > Cc: ES-Discuss; Allen Wirfs-Brock
> > Subject: Re: Function declarations as statements
> >
> > Hi Brendan and Allen,
> >
> > Thanks for the pointers.
> >
> > > So for Harmony, we are reclaiming function in block (must be a direct
> child of
> > a braced block) to bind a block-local name on block entry (so hoisting
> lives, but
> > only to top of block -- so you can't emulate with var f = function ...).
> >
> > If we implemented this behaviour now, I think that would be sufficient to
> make
> > JQuery and Raphaƫl work. Here is an example from JQuery that is giving us
> > trouble:
> >
> > if (condition) {
> >      var val, props, ... ;
> >
> >      function getWH() { ... this is the function ... }
> >
> >      if ( elem.offsetWidth !== 0 ) {
> >          getWH();
> >      } else {
> >          jQuery.swap( elem, props, getWH );
> >      }
> >
> >      return Math.max(0, Math.round(val)); }
> >
> > The getWH() function is declared in the block and only used in the block,
> so if we
> > hoisted the definition to the top of the block there would not be any
> problems
> > with this usage.
> >
> > Best regards,
> >
> > Michael
> >
> > --
> > Print XML with Prince!
> > http://www.princexml.com
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
    Cheers,
    --MarkM
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to