help-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Hi there, a question about typeof()


From: Ivo Palli
Subject: Hi there, a question about typeof()
Date: Sun, 26 Sep 2021 22:05:05 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0

Hiya..

I ran into this:

BEGIN {
split("123", b, "");  # Split a line

print length(b);      # 3 - as it should

print typeof(b[0]);   # unassigned
print typeof(b[1]);   # strnum
print typeof(b[2]);   # strnum
print typeof(b[3]);   # strnum
print typeof(b[4]);   # unassigned

print length(b);      # 5 - euhm, what?

# Like quantum physics, observing changes the observed

exit
}


This is a little unexpected since

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.


Is the manual just vague or is this unwanted behavior (as I personally
think it is)?

Regards,

   Ivo Palli



reply via email to

[Prev in Thread] Current Thread [Next in Thread]