Ingvar von Schoultz wrote: > Igor Bukanov wrote: >> 2008/7/28 Ingvar von Schoultz wrote: <snip> >>>> Any of this can be a valid ES3 code as [] always means an >>>> array literal. >>> I get the impression that disambiguation would be easy. >> >> eval('[]') is a valid and, in fact, useful ES3 code. Similarly >> eval('{[]}'). > > Yes, and by my rules they both create and return a new, empty > array, which is intuitively expected and compatible.
Are you saying that a block then may never be empty as a syntax rule? ES 3 blocks are allowed to be empty and I bet there are examples where blocks contain nothing but an IE/JScript conditional comment and so are going to be interpreted as being empty by other ES 3 implementations. (Comments are allowed inside array literal definitions at present). > When I said that an array is a comma-separated list of values, > the fact that I left out the empty and the single-value cases > didn't mean that they should be seen as blocks! I just didn't > want to write a lengthy, exhaustive full grammar... <snip> { 1,2,3,4,5 } - is a valid ES 3 Program (even if a pointless one); A Block statement containing an Expression statement (with automatic semi-colon insertion making the Expression statement into - 1,2,3,4,5; -). eval('{1,2,3,4,5}') - results in the value 5, while - eval('[1,2,3,4,5]') - returns a 5 element array. _______________________________________________ Es4-discuss mailing list Es4-discuss@mozilla.org https://mail.mozilla.org/listinfo/es4-discuss