5 ms·
Intriguing! I noticed one thing in the handbook: > Care must be taken if you assign a given key to the null value: some platforms remove keys assigned to null
by zestyping 4y ago
Intriguing!
I noticed one thing in the handbook:
> Care must be taken if you assign a given key to the null value: some platforms remove keys assigned to null from tables making them invisible to the in and not in operators.
It is really important to specify the exact behaviour and make sure all platforms behave the same way. You can't write portable programs if the behaviour differs from platform to platform.
- shogundev 4y agoNot happening. If you compile something to Lua assigning a key to nil will erase it, python and javascript will keep it. Pheraps making a special NullObject value to fill these slots would be a good idea, but you could not interact seamlessly with the target system and probably get a speed penalty. Having the exact behavoir in all platforms is not possible in some cases, and these are the cases left 'undefined' in the handbook. Hope this clears things a bit ;) Cheers, -Shogun
- trehans 4y agoWhy not remove the ability to set a key to the null value then? Raise an error in the compiler. It seems pretty undesirable to have undefined behavior in the language, and if high performance is one of your goals, remove the ability for users to do the low performance things.
- a_t48 4y agoRaise an error or just substitute with a deletion
- fbdab103 4y agoThat was a specific call out to Lua without naming it. Definitely one of the regrettable missteps of the language.