4 ms·
What about a special string, i.e. "null" (literally) in the table?
by gnramires 6y ago
What about a special string, i.e. "null" (literally) in the table?
- aasasd 6y agoFirstly, consult any number of articles on what happens when computer systems can't handle ‘null’ as a string, e.g. these two from the past month on HN: https://www.theverge.com/tldr/2019/8/14/20805543/null-license-plate-california-parking-tickets-violations-void-programming-bug https://www.theverge.com/tldr/2019/8/14/20805543/null-licens... and https://www.wired.com/2015/11/null/ https://www.wired.com/2015/11/null/ There was even something in this vein on the front page. Secondly, even if there's another, more special value, that can't be conflated with a string (Lua does support some kind of user-values that are distinct from any built-in types)—it still leaves a question of how different modules handle that. In fact, different modules like CJSON already do this—but what if I decode JSON with CJSON's null value and need to encode XML when the XML module has its own null value? I'd need to walk the data and convert from one to the other. Well, some modules do support a common value denoting null: https://github.com/moteus/lua-null https://github.com/moteus/lua-null But by now why not just have this value in the language, since various modules need it anyway for interoperability with other systems? I heard even that there were attempts at deciding on such a value for a new version of Lua, only with some bunk name like ‘undefined’, which is actually the opposite of what ‘null’ is.