[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: typeof() creates elements in an array
From: |
arnold |
Subject: |
Re: typeof() creates elements in an array |
Date: |
Wed, 29 Sep 2021 00:31:26 -0600 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
"Andrew J. Schorr" <aschorr@telemetry-investments.com> wrote:
> Here's what looks like a more interesting question to me regarding
> this issue.
>
> bash-4.2$ ./gawk 'BEGIN {print typeof(x); x[0] = 0; print typeof(x)}'
> untyped
> array
>
> bash-4.2$ ./gawk 'BEGIN {print typeof(x[0]); x[0][0] = 0; print typeof(x[0])}'
> unassigned
> gawk: cmd. line:1: fatal: attempt to use scalar `x["0"]' as an array
>
> This example does seem to be more at odds with the language in the manual,
Which language in the manual, please?
> since the array element here has been created as a unassigned scalar, not
> as an untyped value. I don't know whether that can be avoided. The array
> instantiation stuff is tricky.
It can't be avoided. This is a backwards compatibility issue. In
standard awk:
BEGIN {
print length(x[0])
}
creates x[0] as unassigned scalar. Gawk can't do anything different
from this. If you want a multidimensional array, you have to
create it that way to start with.
Thanks,
Arnold
- typeof() creates elements in an array, Ivo Palli, 2021/09/27
- 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 <=
- 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