poke-devel
[Top][All Lists]
Advanced

[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?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]