function hoisting like var
Ingvar von Schoultz
ingvar-v-s at comhem.se
Sun Jul 27 18:39:30 PDT 2008
Mike Shaver wrote:
> On Sun, Jul 27, 2008 at 9:15 PM, Ingvar von Schoultz
> <ingvar-v-s at comhem.se> wrote:
>> Does it matter whether it's interpreted as an empty block or
>> an empty discarded array?
>
> It's not always discarded:
>
> js> var x = 1
> js> eval ("if (x) [1, 2, 3]")
> 1,2,3
That becomes an array, no problem. My "Does it matter" was
about empty blocks only, in reply to your question:
>> Are you saying that a block then may never be empty as a syntax
>> rule?
> Does it matter whether it's interpreted as an empty block or
> an empty discarded array?
Array is the default. An empty block gets misinterpreted as an
empty array.
So a code generator that produces an eval that returns a scoping
block must deal with the special case that the block may be empty
or contain a comma-separated list of values. It's the generator's
own fault for producing such silly code, so I don't feel sorry
for that generator. :-)
--
Ingvar von Schoultz
------- (My quirky use of capitals in code comes from my opinion that
reserved and predefined words should all start with lowercase, and
user-defined should all start with uppercase, because this will easily
and elegantly prevent a host of name-collision problems when things
like programming languages are upgraded with new labels.)
More information about the Es4-discuss
mailing list