You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fields that look like numbers compare as strings #150
gawk 5.3.2, mawk and nawk print nothing, 1.0 2, and 50 150 / 1.0 2.
POSIX makes a field that looks like a number a numeric string, so it compares numerically with a number or with another numeric string. Here every field is a plain string (typeof($2) on x 10 prints string; gawk prints strnum), so these comparisons are done byte by byte. The same rule covers getline var, split() elements, ARGV, ENVIRON and -v values.
AwkValue::StrNum exists but nothing creates it yet, so this looks like the planned place for it. Is that the plan? I can send a PR for fields if a direction is agreed.
AwkValue::StrNum exists but nothing creates it yet, so this looks like the planned place for it. Is that the plan? I can send a PR for fields if a direction is agreed.
The problem StrNum has is it's trying to juggle two jobs at once: num/str caching and user input distinction. StrNums ought only be observable via typeof when constructed from external input (records, fields...), but they are still useful to cache a string's numeric value and vice versa (which is what gawk does internally if their docs are anything to go by).
I've reviewed your PR, and came to the conclusion that we really should just bail on using an enum for type representation. It was convenient while it lasted... I would rather do this refactoring, though I'm not going to have the time this week due to my midterm exams.
Activity
Alonely0 commentedon Oct 27, 2026
The problem
StrNumhas is it's trying to juggle two jobs at once: num/str caching and user input distinction.StrNums ought only be observable viatypeofwhen constructed from external input (records, fields...), but they are still useful to cache a string's numeric value and vice versa (which is what gawk does internally if their docs are anything to go by).I've reviewed your PR, and came to the conclusion that we really should just bail on using an enum for type representation. It was convenient while it lasted... I would rather do this refactoring, though I'm not going to have the time this week due to my midterm exams.