digitalmars.D.learn - `enum x;` - what is it?
- Victor Porton (8/8) Aug 19 2020 This declaration does compile:
- FeepingCreature (4/12) Aug 19 2020 It's an enum type whose members we don't know.
- Steven Schveighoffer (12/27) Aug 19 2020 I use it as a symbol for UDAs.
- Victor Porton (7/15) Aug 19 2020 Oh, found: "An empty enum body (For example enum E;) signifies an
- FeepingCreature (5/28) Aug 19 2020 It means exactly what it says. The compiler doesn't know what
This declaration does compile: enum x; But what is it? Is it an equivalent of enum x { } ? What in the specification allows this looking a nonsense enum x; ?
Aug 19 2020
On Wednesday, 19 August 2020 at 14:06:16 UTC, Victor Porton wrote:This declaration does compile: enum x; But what is it? Is it an equivalent of enum x { } ? What in the specification allows this looking a nonsense enum x; ?It's an enum type whose members we don't know. So we can't declare "x var;" but we can declare "x* var;". It's the enum version of "struct SomeExternCStruct;".
Aug 19 2020
On 8/19/20 10:06 AM, Victor Porton wrote:This declaration does compile: enum x; But what is it? Is it an equivalent of enum x { } ? What in the specification allows this looking a nonsense enum x; ?I use it as a symbol for UDAs. enum required; struct S { required int x; } which can then easily be found. What is it? I have no idea. I'm just using the name. I think it's treated as a forward declaration. Kind of like void foo(); -Steve
Aug 19 2020
On Wednesday, 19 August 2020 at 14:06:16 UTC, Victor Porton wrote:This declaration does compile: enum x; But what is it? Is it an equivalent of enum x { } ? What in the specification allows this looking a nonsense enum x; ?Oh, found: "An empty enum body (For example enum E;) signifies an opaque enum - the enum members are unknown." But what this "unknown" does mean? How "unknown" differs from "none" in this context? The specification is unclear. It does not define the meaning of unknown. I will submit a bug report.
Aug 19 2020
On Wednesday, 19 August 2020 at 14:43:22 UTC, Victor Porton wrote:On Wednesday, 19 August 2020 at 14:06:16 UTC, Victor Porton wrote:It means exactly what it says. The compiler doesn't know what members are in the enum. So you can't declare a variable of it, you can't use it directly.. you can p much only use it in pointers.This declaration does compile: enum x; But what is it? Is it an equivalent of enum x { } ? What in the specification allows this looking a nonsense enum x; ?Oh, found: "An empty enum body (For example enum E;) signifies an opaque enum - the enum members are unknown." But what this "unknown" does mean? How "unknown" differs from "none" in this context? The specification is unclear. It does not define the meaning of unknown. I will submit a bug report.
Aug 19 2020