poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC] Syntax for appending elements to arrays


From: Dan Čermák
Subject: Re: [RFC] Syntax for appending elements to arrays
Date: Wed, 25 Nov 2020 23:27:17 +0100

Hi Jose,

"Jose E. Marchesi" <jemarch@gnu.org> writes:
>
> 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.

I'd prefer option 2, as I have grown to hate hidden side effects and
mutability.

>
> A disadvantage of 2) is that not allowing `[1,2,3] + 4' may be
> unexpected for the programmer.

It could be unexpected, but with my functional programming hat on, I'd
rather expect that to create a new array that equals `[1,2,3,4]` but
does not modify `[1,2,3]`. So not having this syntax removes this
ambiguity ;-)


Cheers,

Dan

Attachment: signature.asc
Description: PGP signature


reply via email to

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