Function declarations as statements

Allen Wirfs-Brock Allen.Wirfs-Brock at microsoft.com
Thu Nov 11 17:10:03 PST 2010


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.

Allen

> -----Original Message-----
> From: Michael Day [mailto:mikeday at 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



More information about the es-discuss mailing list