Re: Compile time int to string conversion in BetterC

2022-08-19 Thread bauss via Digitalmars-d-learn
On Friday, 19 August 2022 at 13:47:41 UTC, Paul Backus wrote: On Friday, 19 August 2022 at 10:22:25 UTC, bauss wrote: Is there a reason why .stringof is implementation defined and not clearly defined in the spec how types and declarations should be treated when being "converted to a string"?

Re: Compile time int to string conversion in BetterC

2022-08-19 Thread Paul Backus via Digitalmars-d-learn
On Friday, 19 August 2022 at 10:22:25 UTC, bauss wrote: Is there a reason why .stringof is implementation defined and not clearly defined in the spec how types and declarations should be treated when being "converted to a string"? I find it really odd that it's implementation defined and you

Re: Compile time int to string conversion in BetterC

2022-08-19 Thread bauss via Digitalmars-d-learn
On Thursday, 18 August 2022 at 22:00:06 UTC, Paul Backus wrote: On Wednesday, 17 August 2022 at 11:38:31 UTC, Steven Schveighoffer wrote: On 8/17/22 6:38 AM, Dennis wrote: On Wednesday, 17 August 2022 at 08:44:30 UTC, Ogi wrote: Maybe I’m missing something? I had the same problem, and came u

Re: Compile time int to string conversion in BetterC

2022-08-19 Thread Ogi via Digitalmars-d-learn
On Wednesday, 17 August 2022 at 10:38:33 UTC, Dennis wrote: I had the same problem, and came up with the following trick: ```D enum itoa(int i) = i.stringof; enum major = 3; enum minor = 2; enum patch = 1; enum versionString = itoa!major ~ "." ~ itoa!minor ~ "." ~ itoa!patch; static assert(

Re: Compile time int to string conversion in BetterC

2022-08-18 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 17 August 2022 at 11:38:31 UTC, Steven Schveighoffer wrote: On 8/17/22 6:38 AM, Dennis wrote: On Wednesday, 17 August 2022 at 08:44:30 UTC, Ogi wrote: Maybe I’m missing something? I had the same problem, and came up with the following trick: ```D enum itoa(int i) = i.stringof;

Re: Compile time int to string conversion in BetterC

2022-08-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/17/22 6:38 AM, Dennis wrote: On Wednesday, 17 August 2022 at 08:44:30 UTC, Ogi wrote: Maybe I’m missing something? I had the same problem, and came up with the following trick: ```D enum itoa(int i) = i.stringof; ``` I have the same thing in my code: ```d enum intStr(int x) = x.string

Re: Compile time int to string conversion in BetterC

2022-08-17 Thread Dennis via Digitalmars-d-learn
On Wednesday, 17 August 2022 at 08:44:30 UTC, Ogi wrote: Maybe I’m missing something? I had the same problem, and came up with the following trick: ```D enum itoa(int i) = i.stringof; enum major = 3; enum minor = 2; enum patch = 1; enum versionString = itoa!major ~ "." ~ itoa!minor ~ "." ~