enum confusion
Ali Çehreli
acehreli at yahoo.com
Mon May 9 02:39:21 UTC 2022
On 5/8/22 18:50, Don Allen wrote:
> I'm working on the
> pre-hiatus project again
Welcome back!
> So far, I've been mostly happy with my choice of D
> and much of the work is done, with the core functionality working. The
> code is more concise and readable than the C it came from. Performance
> is absolutely fine. I love the fast compile times (dmd on a FreeBSD
> system) and the ability to debug with gdb.
I am feeling panicky as DConf submission deadline is approaching (May
15, 2022). I would love to watch your report on this project.
> Named Enums,
Check.
> Anonymous Enums
What a strange feature. :)
> and Manifest Constants.
Check.
> "Manifest constants are not
> lvalues, meaning their address cannot be taken. They exist only in the
> memory of the compiler." This can be read to suggest that the other two
> types of enums described *are* lvalues
Yes, unclear wording but no, none of them are lvalues. Equivalent
constructs that I can think of are 'static const' and 'static
immutable'. Those would be evaluated at compile time but have addresses:
static const a = foo();
static immutable b = bar();
int foo() {
return 42;
}
int bar() {
return 43;
}
void main() {
assert(&a != &b);
}
> evaluating all enums at compile time, none of them
> lvalues
YES! :)
Ali
P.S. While looking for traits related to rvalues and lvalues, I realized
that at least isRvalueAssignable() and isLvalueAssignable() do not
appear at the contents section on this page:
https://dlang.org/phobos/std_traits.html
There are issues with Phobos documentation. :/
More information about the Digitalmars-d
mailing list