[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Array literal
From: |
Neil R. Ormos |
Subject: |
Re: [bug-gawk] Array literal |
Date: |
Sun, 26 May 2019 10:24:25 -0500 (CDT) |
Steven Penny wrote:
> Wolfgang Laun wrote:
>> If anything, a built-in function
>> aset( <variable>, <expression>... )
>> with the obvious semantics might be much easier to implement.
> That is a good idea. Something like "aset" or "anew" as a variadic function
> similar to "sprintf" would be great:
> anew(dd, "aa", "bb", "cc")
> dd[2] == "bb"
What additional utility does that provide over the
existing split() function?
At least for initialization values that are
intended to be strings, it doesn't seem to save
much programmer effort. The difficulty of
inspecting the initialization values to select an
appropriate delimiter to be used with split()
is small. With the proposed anew(), the
programmer still must consider whether delimiters
appear in the initialization values and, if so,
escape them.
I suppose with the proposed anew(), one might
expect to be able to use numeric literal constants
in any form gawk recognizes and the resulting
array element would have type "number", whereas
the elements created by split() would have type
"string" or "strnum".