Re: #define-like behavior

2023-03-15 Thread bomat via Digitalmars-d-learn
On Wednesday, 15 March 2023 at 19:27:19 UTC, Paul Backus wrote: It's shorthand for defining an unnamed `enum` with a single member: ... Ah, I see. Thanks!

Re: #define-like behavior

2023-03-15 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 15 March 2023 at 16:40:52 UTC, bomat wrote: Just out of curiosity: Can you explain to me why this is called an `enum` although it's clearly not an enumeration? Seems like a random abuse of a keyword... It's shorthand for defining an unnamed `enum` with a single member: ```d e

Re: #define-like behavior

2023-03-15 Thread bomat via Digitalmars-d-learn
Just out of curiosity: Can you explain to me why this is called an `enum` although it's clearly not an enumeration? Seems like a random abuse of a keyword...

Re: #define-like behavior

2023-03-14 Thread Jeremy via Digitalmars-d-learn
On Tuesday, 14 March 2023 at 06:20:29 UTC, Mike Parker wrote: On Tuesday, 14 March 2023 at 05:47:35 UTC, Jeremy wrote: [...] Manifest constants in D have a similar effect as #defined values, e.g.: [...] Thanks a lot!

Re: #define-like behavior

2023-03-13 Thread Paul Backus via Digitalmars-d-learn
h its value, like #define in C, or will it make a string in memory and refer to that? In D, you can get #define-like behavior by declaring the string as a [manifest constant][1], like this: ```d enum myString = "hello"; ``` For more tips on how to translate C preprocessor idioms to

Re: #define-like behavior

2023-03-13 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 14 March 2023 at 05:47:35 UTC, Jeremy wrote: Hi, in C and C++ you can use #define to substitute a value in place of an identifier while preprocessing. If you initialize a new string and don't change its value after that, will the compiler substitute the string identifier with its va

#define-like behavior

2023-03-13 Thread Jeremy via Digitalmars-d-learn
Hi, in C and C++ you can use #define to substitute a value in place of an identifier while preprocessing. If you initialize a new string and don't change its value after that, will the compiler substitute the string identifier with its value, like #define in C, or will it make a string in memor