Strawman: Tuples

Salvador de la Puente González salva at unoyunodiez.com
Thu Sep 11 04:15:52 PDT 2014


I'm not an expert but the JIT could keep all the lists as tuples until a
modification is performed and then prevent further optimisation.

I don't know if current JITs are already doing this way.
On 10 Sep 2014 23:42, "Jeremy Martin" <jmar777 at gmail.com> wrote:

> Michal - Why have it only throw in strict mode? Tuples would be a new
> construct, so no breaking of the web if it throws in all contexts.
>
> Jasper - It's not necessarily a given, but the immutability of tuples
> offers some guarantees that are easier to optimize against.  E.g., no need
> to pre-allocate extra space, as in most array implementations.
>
>
> On Wed, Sep 10, 2014 at 2:25 PM, Jasper St. Pierre <jstpierre at mecheye.net>
> wrote:
>
>> Why would tuples be any more memory efficient than objects or arrays?
>> On 10 Sep 2014 11:57, "Michał Wadas" <michalwadas at gmail.com> wrote:
>>
>>> Should we have new type - tuples?
>>>
>>> My proposal:
>>> - Tuples are immutable.
>>> Eg.
>>> var wow = new Tuple('my', 'little', 'Cthulhu');
>>> wow[2] = 'Nyarlathotep'; // throws in strict mode, silently fails in
>>> sloppy mode
>>> - Tuples are primitive type. Comparison between tuples is based on
>>> identity of elements, not identity of tuples
>>> Eg:
>>> new Tuple(Object, Function, null, NaN) === new Tuple(Object, Function,
>>> null, NaN); // true
>>> - typeof new Tuple(); // 'tuple'
>>> - Tuple(['wow', 'a', 'b']) = new Tuple('wow', 'a', 'b'); // true
>>> - Tuple.prototype.add = function add() {
>>> return new Tuple(...this, ...arguments);
>>> }
>>>
>>> Pros:
>>> - tuples are very memory efficient
>>> - comparision based on identity of elements is required in many cases
>>> Cons:
>>> - ???
>>> _______________________________________________
>>> es-discuss mailing list
>>> es-discuss at mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
>
> --
> Jeremy Martin
> 661.312.3853
> http://devsmash.com
> @jmar777
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140911/d4ec4759/attachment-0001.html>


More information about the es-discuss mailing list