Re: How to add a character literal to a string without ~ operator?

2024-04-04 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Thursday, 4 April 2024 at 21:23:00 UTC, user1234 wrote: On Thursday, 4 April 2024 at 19:56:50 UTC, Ferhat Kurtulmuş wrote: [...] ```d module runnable; import std.stdio : writeln; import std.range : chain; void main() @nogc { auto s = chain("as ", "df ", "j"); // s is lazy

Re: How to add a character literal to a string without ~ operator?

2024-04-04 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 4 April 2024 at 19:56:50 UTC, Ferhat Kurtulmuş wrote: My favorite d feature is lazy ranges. No allocation here. ```d auto s = chain("as ", "df ", "j"); // s is lazy writeln(s); ``` ```d import std.range : chain; void main() { string word = "hello"; auto noError = chain(word,

Re: How to add a character literal to a string without ~ operator?

2024-04-04 Thread user1234 via Digitalmars-d-learn
On Thursday, 4 April 2024 at 19:56:50 UTC, Ferhat Kurtulmuş wrote: On Thursday, 4 April 2024 at 18:14:54 UTC, BoQsc wrote: I'm looking for more readable standard function to add a **character** literal to a **string**. The `~` operator is clearly not great while reading a source code. I'm

Re: How to add a character literal to a string without ~ operator?

2024-04-04 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Thursday, 4 April 2024 at 18:14:54 UTC, BoQsc wrote: I'm looking for more readable standard function to add a **character** literal to a **string**. The `~` operator is clearly not great while reading a source code. I'm not here to discuss that. I'm looking for a function inside standard

Re: How to add a character literal to a string without ~ operator?

2024-04-04 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 4 April 2024 at 18:14:54 UTC, BoQsc wrote: I'm looking for more readable standard function to add a **character** literal to a **string**. The `~` operator is clearly not great while reading a source code. I'm not here to discuss that. I'm looking for a function inside standard

How to add a character literal to a string without ~ operator?

2024-04-04 Thread BoQsc via Digitalmars-d-learn
I'm looking for more readable standard function to add a **character** literal to a **string**. The `~` operator is clearly not great while reading a source code. I'm not here to discuss that. I'm looking for a function inside standard library. The function should be straightforward, up to

Re: CTFE write message to console

2024-04-04 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 4 April 2024 at 15:47:53 UTC, Richard (Rikki) Andrew Cattermole wrote: Oh hey! https://github.com/dlang/dmd/pull/16250 It was implemented literally 2 weeks ago! Nightly should have it https://github.com/dlang/dmd/releases/tag/nightly Good news, thanks... SDB@79

Re: CTFE write message to console

2024-04-04 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 4 April 2024 at 15:47:53 UTC, Richard (Rikki) Andrew Cattermole wrote: Oh hey! https://github.com/dlang/dmd/pull/16250 It was implemented literally 2 weeks ago! Nightly should have it https://github.com/dlang/dmd/releases/tag/nightly Wow! Happy that's in. It was a bit

Re: CTFE write message to console

2024-04-04 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Oh hey! https://github.com/dlang/dmd/pull/16250 It was implemented literally 2 weeks ago! Nightly should have it https://github.com/dlang/dmd/releases/tag/nightly

Re: CTFE write message to console

2024-04-04 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 4 April 2024 at 15:07:21 UTC, Richard (Rikki) Andrew Cattermole wrote: Ah yes, I forgot about that particular thing, doesn't see much use as far as I'm aware. It should be working though. ```D enum X = computeX("A message"); string computeX(string msg) { auto s = "CTFE

Re: CTFE write message to console

2024-04-04 Thread Carl Sturtivant via Digitalmars-d-learn
On Thursday, 4 April 2024 at 14:06:19 UTC, Richard (Rikki) Andrew Cattermole wrote: ```d static assert(0, "message"); ``` Or if it is known to be CTFE'd ```d assert(0, "message"); ``` Just a warning, its a one time use only for both. No other way to do it. That's ... unfortunate. Some

Re: CTFE write message to console

2024-04-04 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 05/04/2024 4:04 AM, Carl Sturtivant wrote: On Thursday, 4 April 2024 at 14:06:19 UTC, Richard (Rikki) Andrew Cattermole wrote: ```d static assert(0, "message"); ``` Or if it is known to be CTFE'd ```d assert(0, "message"); ``` Just a warning, its a one time use only for both. No other

Re: How to resolve two packages requiring different versions of another package?

2024-04-04 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 05/04/2024 3:29 AM, WhatMeWorry wrote:   Error: Unresolvable dependencies to package bindbc-loader:   bindbc-opengl 0.13.0 depends on bindbc-loader ~>0.3.0   bindbc-sdl 1.4.7 depends on bindbc-loader ~>1.1.0 https://github.com/BindBC/bindbc-opengl/issues/47

Re: CTFE write message to console

2024-04-04 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 05/04/2024 2:54 AM, Carl Sturtivant wrote: I'm writing CTFE on Windows, latest DMD compiler. How should I write a message to the console (stderr) from a CTFE function call during compilation? ```d static assert(0, "message"); ``` Or if it is known to be CTFE'd ```d assert(0, "message");

How to resolve two packages requiring different versions of another package?

2024-04-04 Thread WhatMeWorry via Digitalmars-d-learn
Error: Unresolvable dependencies to package bindbc-loader: bindbc-opengl 0.13.0 depends on bindbc-loader ~>0.3.0 bindbc-sdl 1.4.7 depends on bindbc-loader ~>1.1.0

Re: How best to implement items and weapons in my RPG. Nested classes? Delegates?

2024-04-04 Thread Olivier Pisano via Digitalmars-d-learn
Hi, You should have a look at the decorator design pattern, it reduces the amount of classes to implement if you need to combine different effects such as elemental damage to your weapons (e.g. if you want flame arrows). https://en.wikipedia.org/wiki/Decorator_pattern