[Issue 23544] Allow enum types be defined with semicolons

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 22 12:41:57 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=23544

--- Comment #3 from Bolpat <qs.il.paperinik at gmail.com> ---
(In reply to mhh from comment #2)
> What would a static foreach inside an enum (without use of mixin) be able to
> express?

You can generate members based off of other members. It’s very similar to
`static foreach` generating `case` labels in a `switch` statement. Note that
you excluding mixin proves my point, that is a use case. A relevant observation
is that how well string mixins can be understood correlates strongly with their
length: A simple, single declaration string mixin inside a `static foreach` is
vastly preferable to a string mixin creating the enum and its members in one
go.

As another example, conditional compilation using `static if` can make members
(un)available depending on compile-time information. There’s lots of potential
examples where one would like that. An enum member can specify certain actions,
some of which might not be available on e.g. certain architectures.

--


More information about the Digitalmars-d-bugs mailing list