lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Mar 5, 2012 at 1:14 PM, Jay Carlson <nop@nop.com> wrote:
>> In addition, the ability to add a trailing comma makes adding new items
>> to the list and rearranging the order of the list items less of a hassle
>> in Lua than in JavaScript.
>
> I got screwed by expecting JavaScript to do the right thing. In C, it makes perfect sense to imply a trailing NULL entry. In languages that carry length with arrays, no.

i don't think that was about NULL termination, but that in some
languages, the last element of a list or dictionary can have a
trailing comma; but in JavaScript this is undefined.

for example, in Lua these tables are identical:
[1,2,] == [1,2]
also:
[a=1,b=2,] == [a=1,b=2]

in Python:
[1,2,] == [1,2]
and
{'a':1,'b':2,} == {'a':1,'b':2}

but in JavaScript, the following are undefined:
[1,2,]
{'a':1,'b':2,}
in most implementations this works as expected; but in IE it fails at runtime.


-- 
Javier