[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Exposing emum flags from the C-API
- From: Jonathan Goble <jcgoble3@...>
- Date: Fri, 15 Jul 2022 13:49:31 -0400
Op Thu, 14 Jul 2022 22:47:56 +0200 schreef Jonathan Goble <email@example.com>:
> To solve the boolean issue, I would suggest adding a method to `perms`
> objects. Example:
> if perms.owner_write:in(variable_with_permissions) then
> -- ...
> ...except `in` is a reserved keyword and I don't know what would best
> replace it. (Naming things is hard!)
Something like that crossed my mind and use functions like 'test', 'set' and 'clear' instead of binary operators.
But I had hard time to make up a nice API to construct a new value from multiple flags.
You don't have to abandon binary operators. Operators and methods can coexist, each serving their own purposes.
The advantage of functions over the binary operators is that library may gain compatibility for Lua 5.2 and 5.1
True, though I question how important that compatibility is given that both are end-of-life. Although 5.1 in particular still has some significant use in the wild.