Hello,

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 -- https://github.com/jashkenas/coffee-script/issues#issue/827 . 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: https://github.com/DmitrySoshnikov/es-laboratory/blob/master/examples/array-negative-indices.js (example), https://github.com/DmitrySoshnikov/es-laboratory/blob/master/src/array-negative-indices.js (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.

Toughs?

Dmitry.
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to