[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
typeof() creates elements in an array
From: |
Ivo Palli |
Subject: |
typeof() creates elements in an array |
Date: |
Mon, 27 Sep 2021 20:35:27 +0200 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 |
Hiya,
After sparring about this on the help mailinglist, I decided to upgrade
this to a bug.
This:
split("123", arr, "");
print typeof(arr[0]);
creates a new element on arr[0]. (length(arr)==4)
This is unexpected since the manual
https://www.gnu.org/software/gawk/manual/html_node/Type-Functions.html
says:
> Normally, passing a variable that has never been used to a built-in
> function causes it to become a scalar variable (unassigned). However,
> isarray() and typeof() are different; they do not change their arguments
> from untyped to unassigned.
As a regular user I would not expect new elements to be created, and
honestly I don't see this behavior as useful. I suggest changing it so
new elements are not created anymore. If this can not be done due to
language constructs for example, I suggest adding a caveat in the manual.
Regards,
Ivo Palli
- typeof() creates elements in an array,
Ivo Palli <=
- Re: typeof() creates elements in an array, david kerns, 2021/09/28
- Re: typeof() creates elements in an array, Andrew J. Schorr, 2021/09/28
- Re: typeof() creates elements in an array, arnold, 2021/09/29
- Re: typeof() creates elements in an array, Andrew J. Schorr, 2021/09/29
- Re: typeof() creates elements in an array, arnold, 2021/09/29
- Re: typeof() creates elements in an array, arnold, 2021/09/30
- Re: typeof() creates elements in an array, Andrew J. Schorr, 2021/09/30
- Re: typeof() creates elements in an array, arnold, 2021/09/30
- Re: typeof() creates elements in an array, Andrew J. Schorr, 2021/09/30
Re: typeof() creates elements in an array, arnold, 2021/09/29