Re:Aho – a Git implementation in Awk
by bagful on Saturday February 10, 2024 @07:38PM
(#39331652)
I love AWK. Its stringly-typedness would make a Javascript programmer blush: 0, “”, and actually-nothing are identically falsey. Numbers are no different from strings representing numbers, like Lua. Somehow, I don’t mind — if you really need to keep your numbers numbers and strings strings, sigilate the value (prepend with #/$) and peel it off with a substr() later.
[ Parent
| on HN ]
Re:Aho – a Git implementation in Awk
by garaetjjte on Saturday February 10, 2024 @07:58PM
(#39331761)
Lua does not represent numbers with strings. It does have number type which is always floating-point.
Integers were introduced in 5.3.
I like the way Lua handles strings and numbers quite a bit. They're different types, but arithmetic will convert a string to a number when it can.
This is without footguns, because concatenation is a different operator entirely.
2 + "3" -- 5
2 .. "3" -- "23"
It's rather convenient, especially when you can combine it with LPeg to parse files with numbers in them, then do the maths directly.