Negative indices for arrays

Dmitry A. Soshnikov dmitry.soshnikov at
Thu Nov 11 02:24:08 PST 2010


How likely (based on backward compats) that Harmony will support 
Pythonic negative indices for arrays? Ruby supports them too. There was 
previous indirect mention, were Brendan agreed that Harmony needs such a 
semantics for arrays, however, that discussion wasn't formed to 
something concrete.

Recently, there was the same discussion in CoffeeScript's tracker -- . Since 
Coffee uses JavaScript as its lower level, there were proposals to 
provide an alternative syntax for this (e.g. a[* - 1], where * means 
a.length, allowing this feature to be generic), though, I'm not sure 
this exact syntax is needed for ES. However, I mentioned there, that if 
Harmony itself will support this feature in Python's/Ruby's semantics, 
then Coffee won't need an alternative thing.

Currently, this feature may be easily implemented using proxies: 
(implementation), however possibly it's good to have this semantics for 
objects with [[Class]] "Array" as native. I think it's acceptable, since 
we already have such alternative semantics for String objects.



More information about the es-discuss mailing list