Newbie style question about string constants

FeepingCreature feepingcreature at gmail.com
Mon Mar 31 05:56:48 UTC 2025


On Thursday, 27 March 2025 at 06:20:25 UTC, cc wrote:
> I got in the habit of using `static immutable` whenever 
> possible as enum just can't be trusted to use CTFE.
>
> ```d
> enum string RfuncName = fullyQualifiedName!...
> // Oops! Allocates on runtime every frame this is referenced
> enum string funcName = RfuncName.crc32Of.toHexString();
> ```

Woah! I was like "this surely can't be right" but it is... array 
literal per use because of the implicit string conversion, wow. 
File a bug for that?

Amusingly, this works correctly: `enum string funcName = 
RfuncName.crc32Of.toHexString().idup;`


More information about the Digitalmars-d-learn mailing list