-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
turn enum
into @enum
#85
Comments
The current implementation of enums is kinda bad already because it doesn't really have named enums (which I prefer). And also it is would be better to remain a keyword |
If you mean Rust's those are too complex and don't feel necessary in Clue (since tables) |
No that. I just mean that the enum should have a name. The variants won't really have any value with them. enum Something{
A,
B
} |
A name would really only be useful for type checking, which is not yet a thing |
but we don't really need types to implement it it would just be compiled to a table |
That is..unnecessary? |
The point of enums is to define state constants more quickly |
but we still need good lua interoperability |
What? |
if you were to make a library which should also work in lua the the enum must be easy to use to use in lua |
I guess that's fair |
How about just having both enum and @enum? Edit: ...that pinged somone, oops |
I guess if the difference is clear for everyone it they can satisfy both use cases |
|
no need |
I mean |
what if somebody wanted to just use a named enum in the local scope? |
They use |
but @enum is not a named enum, which has some use cases outside of a library |
I doubt naming enums will be useful.. |
it still has its uses and I would use it for some things |
Forgot to reply- |
I use them all the time they are extremely useful |
You use the name all the time? |
Yes I name my enums. Being able to have a single named enum with values of simple names like say FileMode.Read (C# style enum) is very very helpful for code readability and just writing the code in general. Even in my own Lua enum implementation I use a named enum setup. I see enums as a group of number constants that belong to a single "type" which is the name. Without that name they lose a chunk of their meaning |
Enum values are almost always prefixed with a shared name for organization no matter the language so why not just group them under that name automatically with a named enum system. Cutting out the need to manually type that prefix each time. |
Because Clue does not have types (yet) so the name would not be used |
?????? That doesn't mean anything? They should all have the type be used somewhere in calling them? Like C# does Type.Value and my Lua implementation initially used Type_Value. (I have since swapped to C# style) |
The point is making them visibly related to each other along with type checking. Not exclusively type checking. |
How could Clue store a type inside a number? |
By defining the type as the name of an enum you'd tell the compiler "hey if the provided value doesn't come from an enum value in this name group throw an error" |
Could I have an example of valid and invalid code? |
Here's a quick example using C# style names |
I see, makes more sense now |
when converting old 2.5 code to 3.0 I noticed I changed all enums to a bunch of
@define
, which made me realiseenum
would work better as a preprocessor directive that sets many preprocessor variablesThe text was updated successfully, but these errors were encountered: