3 ms·
Edit: I said Tcl, but that has the opposite problem: integers are fine, but floating point is problematic because everything is strings. Updated below to remov
by martincmartin 5y ago
Edit: I said Tcl, but that has the opposite problem: integers are fine, but floating point is problematic because everything is strings. Updated below to remove Tcl.
I don't think this is true of most languages; only for Lua that I know of. And it causes problem: if you send a 64-bit ID to Lua, which represents it as a double, it will subtly change the last few bits. Then when you go to look up something with that ID, you get the wrong item.
Most languages don't have that problem.
- secondcoming 5y agoYes, I couldn't believe Lua chose this path. We have to use Lua scripts with Redis and this conversion stuff concerns me.
- ptx 5y agoI don't know much about Tcl, but I thought everything was a string, not a float? It appears to work with integers just fine: $ echo 'puts [expr 2 ** 128 + 1]' | tclsh 340282366920938463463374607431768211457 $ python3 -c 'print(2 ** 128 + 1)' 340282366920938463463374607431768211457 $ node -p 'Math.pow(2, 128) + 1' 3.402823669209385e+38
- martincmartin 5y agoYeah good point, I updated my comment. Thanks!
- tpoindex 5y agoTcl hasn't been string based for 20 years, misinformation is hard to eliminate. Since the release of version 8.0 in 2001, Tcl internally has value types for integer, bigints, double, boolean, lists, etc.. As long as you're careful not to cause the internal value to 'shimmer' into a string representation, Tcl maintains the value type as last used. Tcl happily converts values to strings as needed, giving the impression of 'everything is a string'.
- kevin_thibedeau 5y agoTcl hasn't been string based for 20+ years. It used boxed objects ever since the bytecode interpreter was added in 8.0.