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
On Monday, 24 February 2025 at 16:07:07 UTC, Ian wrote:
Hello,
What's the recommended D way to declare a string constant? Say,
for example, for a path used inside a class constructor? I've
seen const string, immutable, enum etc...
Is this the place for these kinds of questions? Is there a D
On Monday, 17 March 2025 at 08:27:17 UTC, Jonathan M Davis wrote:
In any case, the normal way in D to declare a string constant
is to use enum. So, that's primarily what you're going to see
in most code. Whether you choose to do that in your own code is
up to you.
- Jonathan M Davis
Hi Jo
On Sunday, 16 March 2025 at 15:22:04 UTC, Ian wrote:
It seems that in some cases static immutable is preferred, so
why not use that always then, rather than having to keep two
cases in my head?
Enum is the indispensable one, immutable isnt important just
theres a subsection of the community t
On Sunday, March 16, 2025 9:22:04 AM MDT Ian via Digitalmars-d-learn wrote:
> On Tuesday, 25 February 2025 at 00:34:45 UTC, Jonathan M Davis
> wrote:
> > For strings, the way that you normally do constants is with
> > enum, e.g
> >
> > enum foo = "dlang";
> >
> > An enum like this is called a m
On Tuesday, 25 February 2025 at 00:34:45 UTC, Jonathan M Davis
wrote:
For strings, the way that you normally do constants is with
enum, e.g
enum foo = "dlang";
An enum like this is called a manifest constant. And you use
manifest constants for most constants in D, with the caveat
that fo
On Monday, February 24, 2025 9:07:07 AM MST Ian via Digitalmars-d-learn wrote:
> Hello,
>
> What's the recommended D way to declare a string constant? Say,
> for example, for a path used inside a class constructor? I've
> seen const string, immutable, enum etc...
>
> Is this the place for these kin
On Monday, February 24, 2025 11:19:48 AM MST Elias Batek (0xEAB) via
Digitalmars-d-learn wrote:
> For string constants you’ll usually want to mark them as `static
> immutable`. Strings with this combination will usually be put
> into read-only sections (ROM) of the resulting binaries.
>
> Unlike `
On Monday, 24 February 2025 at 16:07:07 UTC, Ian wrote:
Hello,
What's the recommended D way to declare a string constant? Say,
for example, for a path used inside a class constructor? I've
seen const string, immutable, enum etc...
Is this the place for these kinds of questions? Is there a D
On Monday, 24 February 2025 at 16:07:07 UTC, Ian wrote:
Hello,
What's the recommended D way to declare a string constant? Say,
for example, for a path used inside a class constructor? I've
seen const string, immutable, enum etc...
enum vs value is a tradeoff of when a decision is made; not s
Hello,
What's the recommended D way to declare a string constant? Say,
for example, for a path used inside a class constructor? I've
seen const string, immutable, enum etc...
Is this the place for these kinds of questions? Is there a D
stack overflow?
Cheers,
Ian
11 matches
Mail list logo