[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
signature.asc
Description: PGP signature
- [RFC] Syntax for appending elements to arrays, Jose E. Marchesi, 2020/11/25
- 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 <=
- 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