On Thursday, 17 September 2020 at 10:56:28 UTC, Mike Parker wrote:
On Thursday, 17 September 2020 at 09:44:20 UTC, claptrap wrote:
Seriously how it's implemented is irrelevant.
And to be clear, my point wasn't about how it's implemented. My
point was that:
enum { foo = 10; }
and
enum foo = 10;
Are effectively the same thing, whether it's implemented that
way or not. So why on earth would a new keyword be necessary?
I could imagine some new users may think in
enum foo = someTemplate!();
someTemplate could evaluate to a list of values like a 'normal'
enum. That's just conjecture, though. The one thing I dislike
about enum like this is that we have another keyword that's able
to handle manifest constants when tickled correctly, and which
doesn't evoke the image of an enumerated list of values:
import std.meta : Alias;
alias foo = Alias!([1,2,3]);
alias bar = Alias!9;
alias baz = Alias!someFunc;
Some of the above may be doable without Alias!(), but not all. I
don't know if you remember the discussions when bracketless enums
were introduced back in 2007ish, but alias was the prime
contender back then, and is slowly gaining the power that was
requested at the time (the ability to alias values as above was
added fairly recently).
To quote Bill Baxter from way back when
(https://forum.dlang.org/post/fjdc4c$2gft$1...@digitalmars.com):
> Why does:
> final int x = 3;
> make any more intuitive sense than:
> enum int x = 3;
> ?
There are these things called "words". And they have
"meanings"...
enum: (short for "enumeration", the noun form of "enumerate")
"to specify one after another : list"
final:
"not to be altered or undone <all sales are final>"
To be clear: I don't mind 'enum' being used this way, but if I
were to do things over again, I would have used 'alias'.
--
Simen