[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC] Syntax for appending elements to arrays
From: |
Jose E. Marchesi |
Subject: |
[RFC] Syntax for appending elements to arrays |
Date: |
Wed, 25 Nov 2020 10:06:16 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Hi people!
At the moment we support concatenating arrays by creating new array
values:
[1,2,3] + [4,5,6] -> evaluates to a new array value [1,2,3,4,5,6]
However, in poke we can have really BIG arrays, and the above can become
problematic in terms of memory consumption and also performance.
So I suggest adding syntax to append new elements to existing array
values. I see two options here:
1) To do it in an expression, like:
[1,2,3] + 4 -> appends 4 to the given array and then evaluates to
the modified array.
This would of course imply the availability of the corresponding
statement:
var a = [1,2,3];
a += 4;
2) To only allow the statement form:
var a = [1,2,3];
a += 4;
I think I am inclined for 2) more than for 1), because it makes the
side-effect more explicit.
A disadvantage of 2) is that not allowing `[1,2,3] + 4' may be
unexpected for the programmer.
Opinions?
- [RFC] Syntax for appending elements to arrays,
Jose E. Marchesi <=
- Re: [RFC] Syntax for appending elements to arrays, Mohammad-Reza Nabipoor, 2020/11/25
- Re: [RFC] Syntax for appending elements to arrays, Dan Čermák, 2020/11/25
- Re: [RFC] Syntax for appending elements to arrays, Jose E. Marchesi, 2020/11/26
- Re: [RFC] Syntax for appending elements to arrays, Mohammad-Reza Nabipoor, 2020/11/26
- Re: [RFC] Syntax for appending elements to arrays, Jose E. Marchesi, 2020/11/27
- Re: [RFC] Syntax for appending elements to arrays, Jose E. Marchesi, 2020/11/27
- Re: [RFC] Syntax for appending elements to arrays, Egeyar Bagcioglu, 2020/11/27
- Re: [RFC] Syntax for appending elements to arrays, Jose E. Marchesi, 2020/11/27
- Re: [RFC] Syntax for appending elements to arrays, Egeyar Bagcioglu, 2020/11/27
- Re: [RFC] Syntax for appending elements to arrays, Jose E. Marchesi, 2020/11/27