Re: What does @nogc do to a class?
On Thursday, 6 May 2021 at 01:04:02 UTC, Jack wrote: Does it allocate the object rather on stack, like auto scope a = new A or what? It doesn't do anything to classes. `@nogc` prevents you from any action triggers a GC allocation, such as using `new, so you would need to allocate from somewhere else (e.g., via `malloc`) for any class instances you want to create in a `@nogc` function.
What does @nogc do to a class?
Does it allocate the object rather on stack, like auto scope a = new A or what?
Re: dlang vs crystal-language
On Wednesday, 5 May 2021 at 18:50:05 UTC, Alain De Vos wrote: What's wrong with WSL. I think it is a great idea. What Imperatorn said is the write thing. Sorry for not being clear.
Re: dlang vs crystal-language
On Wednesday, 5 May 2021 at 18:50:05 UTC, Alain De Vos wrote: On Friday, 30 April 2021 at 14:16:16 UTC, Vinod K Chandran wrote: On Wednesday, 28 April 2021 at 22:41:03 UTC, Alain De Vos wrote: [...] Pros of **Crystal** 1. Attractive syntax. I like Ruby like syntax. It's really expressive. Cons of Crystal 1. It doesn't have a compiler for Windows. It uses WSL based compiler and I think it's a bad idea. I don't think I need to tell the pros & cons of **D lang** in it's own forum. BTW, I wonder to see someone says that they have succeeded in compiling a **tkD** example code. I tried it with no luck. So I gave up that idea. What's wrong with WSL. I think it is a great idea. Maybe he meant WSL is good, but relying on it for Windows support is suboptimal. I kinda agree
Re: dlang vs crystal-language
On Friday, 30 April 2021 at 14:16:16 UTC, Vinod K Chandran wrote: On Wednesday, 28 April 2021 at 22:41:03 UTC, Alain De Vos wrote: What are the strengths and weaknesses comparing the two languages ? I can name a strength of dlang is the working binding to tk and gtk. Pros of **Crystal** 1. Attractive syntax. I like Ruby like syntax. It's really expressive. Cons of Crystal 1. It doesn't have a compiler for Windows. It uses WSL based compiler and I think it's a bad idea. I don't think I need to tell the pros & cons of **D lang** in it's own forum. BTW, I wonder to see someone says that they have succeeded in compiling a **tkD** example code. I tried it with no luck. So I gave up that idea. What's wrong with WSL. I think it is a great idea.
Re: How to check for combinations of versions
On Wednesday, 5 May 2021 at 15:25:31 UTC, Paul Backus wrote: However, if you really want something more expressive, and are confident in your ability to use the extra power responsibly, it is possible to work around these limitations: template hasVersion(string identifier) { mixin( "version(", identifier, ") enum hasVersion = true;", "else enum hasVersion = false;" ); } Hmm, I'll keep this in mind in case things start getting start getting more out of hand. Thanks! :) Mixin strings are still kind of like black magic to me, so I prefer not to use them unless I really think they would help a lot. In this case, I only do this 3 times in the entire codebase, so it's not worth it yet. And Dennis, sadly that wouldn't work for me since `version = XYZ` only affects the current module and I'm using this check in multiple modules. Thanks for the help!
Re: EMSI Containers and HashMap of HashMaps
On Sunday, 2 May 2021 at 07:38:03 UTC, Tobias Pankrath wrote: For your convenience: https://run.dlang.io/is/gHSlu1 I am using Refcounted() because HashMap itself is not copy-able. Is there another way to have HashMaps as values of HashMaps? I've figured it out and filed an PR https://github.com/dlang-community/containers/pull/169. Would be great if we can get a new version out with this.
Re: How to check for combinations of versions
On Wednesday, 5 May 2021 at 15:03:16 UTC, Blatnik wrote: Is there any way to check for multiple conditions in a `version` statement? No, and that's by design to discourage complex version logic. The recommended approach is: ```D version (Version_A) version = Cool_Feature_Supported; version (Version_B) version = Cool_Feature_Supported; void do_something_cool() { version(Cool_Feature_Supported) { ... } else { ... } } ```
Re: How to check for combinations of versions
On Wednesday, 5 May 2021 at 15:03:16 UTC, Blatnik wrote: Currently I resort to something like this, but I'm curious if there's a nicer way to do it. ```D version (Version_A) { enum Cool_Feature_Supported = true; } else version (Version_B) { enum Cool_Feature_Supported = true; } else { enum Cool_Feature_Supported = false; } ``` This is the officially-recommended way to do it. D's `version` system is deliberately restricted, in order to avoid the "`#ifdef` hell" that often plagues C and C++ projects. However, if you really want something more expressive, and are confident in your ability to use the extra power responsibly, it is possible to work around these limitations: template hasVersion(string identifier) { mixin( "version(", identifier, ") enum hasVersion = true;", "else enum hasVersion = false;" ); } // Usage static if (hasVersion!"Version_A" || hasVersion!"Version_B") { enum Cool_Feature_Supported = true; } else { enum Cool_Feature_Supported = false; }
How to check for combinations of versions
Is there any way to check for multiple conditions in a `version` statement? For example, my platform may have `Version_A` and `Version_B`, and both versions provide some shiny feature I want to use. Is there some nice way to write: ```D version (Version_A || Version_B) { // Use the cool feature. } else { // Do something less cool but portable. } ``` Currently I resort to something like this, but I'm curious if there's a nicer way to do it. ```D version (Version_A) { enum Cool_Feature_Supported = true; } else version (Version_B) { enum Cool_Feature_Supported = true; } else { enum Cool_Feature_Supported = false; } ... void do_something_cool() { static if (Cool_Feature_Supported) { ... } else { ... } } ```