[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: unassigned/untyped behaviour
From: |
arnold |
Subject: |
Re: unassigned/untyped behaviour |
Date: |
Tue, 21 Nov 2023 21:33:52 -0700 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
Hi.
"Andrew J. Schorr" <aschorr@telemetry-investments.com> wrote:
> > > For example:
> > >
> > > BEGIN {
> > > # creates a[1] but it has no assigned value
> > > a[1]
> > > print typeof(a[1]) # unassigned
> > > }
> > >
> > > But in fact, that's not what the master branch produces:
> >
> > That example is bad. I will fix the doc.
>
> On 2nd thought, I don't understand why the doc is wrong. Doesn't the statement
> "a[1]" actually instantiate a[1] as an unassigned scalar value?
No, it creates a[1] as an *untyped* value, neither array nor scalar.
"unassigned" IS scalar. "untyped" is neither fish nor fowl, until
we see how it gets used.
> In other words, is it proper to do this?
>
> gawk 'BEGIN {a[0]; a[0][1] = 5; print a[0][1]}'
Entirely proper, _because_ we don't know what a[0] is until
the second statement.
I may be able to have
a[1]
printf("%d", a[1])
print typeof(a[1])
print "unassigned" instead of "numeric". That would make it
become exactly parallel to the scalar case:
a
printf("%d", a)
print typeof(a)
I'm going to try it.
Thanks,
Arnold
- unassigned/untyped behaviour, M, 2023/11/16
- Re: unassigned/untyped behaviour, Andrew J. Schorr, 2023/11/16
- Re: unassigned/untyped behaviour, Andrew J. Schorr, 2023/11/16
- Re: unassigned/untyped behaviour, arnold, 2023/11/21
- Re: unassigned/untyped behaviour, arnold, 2023/11/21
- Re: unassigned/untyped behaviour, Andrew J. Schorr, 2023/11/21
- Re: unassigned/untyped behaviour,
arnold <=
- Re: unassigned/untyped behaviour, arnold, 2023/11/22
- Re: unassigned/untyped behaviour, Andrew J. Schorr, 2023/11/22
- Re: unassigned/untyped behaviour, arnold, 2023/11/22
- Re: unassigned/untyped behaviour, Andrew J. Schorr, 2023/11/22
- Re: unassigned/untyped behaviour, M, 2023/11/22
- Re: unassigned/untyped behaviour, arnold, 2023/11/28