bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Another typeof() issue


From: Hermann Peifer
Subject: Re: [bug-gawk] Another typeof() issue
Date: Sun, 28 Jun 2015 22:28:44 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

Maybe typeof() could also indicate if the variable has the strnum type,
as explained in the manual: 6.3.2.1 String Type versus Numeric Type

Hermann

This is a nice thought. It's on my todo list, I hope by end of day today.


Thanks for taking care. When looking at fields, the results of typeof() are somewhat different to my expectations, but maybe these are wrong (?).

Hermann

$ echo "abc 123" > data
$ echo '{print typeof($1), typeof($2)}' > test.awk

# Expected types: string strnum
$ awk -f test.awk data
strnum strnum

# Debugging returns the opposite of the expected results
$ printf 'w $1 \n w $2 \n r \n n \n n' | awk -D -f test.awk data
Watchpoint 1: $1
Watchpoint 2: $2
Starting program:
Stopping in Rule ...
Watchpoint 1: $1
  Old value: ""
  New value: "abc"
main() at `test.awk':1
1       {print typeof($1), typeof($2)}
Watchpoint 2: $2
  Old value: ""
  New value: "123"
main() at `test.awk':1
1       {print typeof($1), typeof($2)}
strnum string  # ???




reply via email to

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