Replies: 1 comment
-
Related, from The Evolution of Lua:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Maybe I am missing the genius but this “lua enhancement” seems to have limited uses (building TUI frames??). More seriously though, it is inconsistent with pre-exisiting Lua string multiplication which will interpret a string as a number if possible and error otherwise.
Standard Lua:
redbean:
I'm not going to defend the implicit coercion in standard Lua. But the redbean behavior seems the worst of many worlds:
I propose removing this feature. In particular the
'2' * 2
behavior seems potentially disastrous. A defensive programmer should of course validate and “cast” strings to numbers before arithmetic, but a lazy programmer (me in many situations) will be perfectly happy with a runtime error if a coercion fails.Example:
Of course, an easy fix is
a = arg[1] + 0
in the script, but it is only easy if you anticipate the need.Beta Was this translation helpful? Give feedback.
All reactions