[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ 5.4 ] Sequence Iteration - Knowing when to Stop?
- From: ThePhD <jm3689@...>
- Date: Fri, 1 Jun 2018 15:41:43 -0400
It's less of a problem when you write in purely Lua and extremely easy to work around, I agree.
In C++ it's a semi-regular thorn that reminds me when I spend too much time away from Lua. If I'm building something type-safe on top of Lua, using `false` to signal `nil` or similar does not exactly work properly. It's not impossible to work around, but convincing someone that serializing `nullptr` from C or C++ as `false`, some library-specific `USERDATA_NIL` (which is even harder to implement under 5.1 and 5.2 userdata comparison rules from metatable equality constraints), or other is an extremely hard sell. It's also even harder when someone places `nil` in a table that's expected to be a sequence and try to get that sequence out as, say, a `std::vector<my_type*>`. It just doesn't line up proper a lot with the types...
(Consequently, this is another reason why strict type safety is entirely optional in my opinion when building these things, which has earned me some grilling from colleagues before, but...)