Use of GUID constants
Mike Parker via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Mar 10 05:49:56 PST 2016
On Thursday, 10 March 2016 at 10:16:30 UTC, KlausO wrote:
> Ok, but what's the intention behind defining GUIDs as enums in
> the first place ?
Probably just an implementation error, i.e. someone not fully
appreciating how GUIDs are intended to be used.
> Is there a recommended way to declare/define constants (e.g. as
> enums or consts) ?
Generally, you should use a manifest constant, e.g.
enum myConst = 10;
Unless you need to take the address, then you should use
immutable:
immutable myConst = 10;
The value of a manifest constant is substituted for the symbol at
the point of use and is not stored in the data segment (so has no
memory address), but an immutable (or const) variable is stored
in the data segment.
More information about the Digitalmars-d-learn
mailing list