7 ms·
If any of the Luau devs are watching this, please flesh out the metamethods. I'd switch almost everything to Luau if they were improved. They're the biggest PI
by junon 5y ago
If any of the Luau devs are watching this, please flesh out the metamethods. I'd switch almost everything to Luau if they were improved.
They're the biggest PITA right now as designed in PUC-Rio, and I see that while you've improved upon __eq, other metamethods are still lacking.
In PUC-Rio, boolean equality operators FORCE a boolean result, regardless of what you return. Ideally they would allow returning any result type, which then can be coerced to boolean later (e.g. by an `if` statement), just like the arithmetic operators do.
Further, `__neq`, `__ge` and `__gt` do not exist. They should.
The lack of a proper metamethod design means that binding to e.g. Kiwi[0] is impossible without some incredibly fugly hacks. It has been a long-standing annoyance with Lua in an otherwise beautiful little scripting language (that I use frequently).
This looks quite nice - lots of attempts in this space but nothing that attempts to match Lua to this degree.
[0] https://github.com/nucleic/kiwi https://github.com/nucleic/kiwi
- deleted 5y ago[deleted]
- deleted 5y ago[deleted]
- junon 5y agoActually went ahead and wrote an RFC for this: https://github.com/Roblox/luau/pull/109 https://github.com/Roblox/luau/pull/109
- adontz 5y ago>> Further, while >= and > can both be reversed to <= and < (and thus adding them in this RFC might be considered excessive or unnecessary) False. You need all operators because for database NULL-alike logic you cannot infer results from one half of operators. NULL < NULL == false NULL > NULL == false
- pansa2 5y agoCan’t you rewrite the second of those so it becomes the first, hence rewriting `>` into `<`?
- adontz 5y agoNo. NULL compared to anything in any way is false. http://sqlfiddle.com/#!4/d8fff5/14/0 http://sqlfiddle.com/#!4/d8fff5/14/0 http://sqlfiddle.com/#!17/9eecb/83597/0 http://sqlfiddle.com/#!17/9eecb/83597/0 http://sqlfiddle.com/#!18/9eecb/142653/0 http://sqlfiddle.com/#!18/9eecb/142653/0
- pansa2 5y agoYou still don’t need `>` for any of those examples though, do you? For example, `NULL > 1` could be rewritten as `1 < NULL` (even though it can’t be rewritten as `not(NULL <= 1)`.
- adontz 5y agoWhat do you mean by rewritten? In func_a() > func_b() I expect left-to-right execution order. Not that it should matter in a good code, but anyway.
- junon 5y agoI agree entirely, you should comment on the RFC for this usecase (binding to database objects). It would be super helpful. :)