Re: How debugg unittest with visual code + code-d

2020-06-06 Thread Luis via Digitalmars-d-learn
On Friday, 5 June 2020 at 18:13:52 UTC, WebFreak001 wrote: To build before running the debugger, add the following task to your task definitions file (Ctrl-Shift-B): { "label": "dub build", // <-- add a good name here "type": "dub", "run": false, "buildType":

Re: Should it compile?

2020-06-06 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 6 June 2020 at 11:58:06 UTC, Basile B. wrote: On Saturday, 6 June 2020 at 08:55:20 UTC, Jack Applegame wrote: Should it compile? I think, it should. maybe it shouldn't but then with another message, for example Error, cannot `void` initialize a `const` declaration. since

Re: Should it compile?

2020-06-06 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 6 June 2020 at 12:54:38 UTC, Stanislav Blinov wrote: The moveEmpalce should compile... But not when the *first* argument is const though, like in the example. For *that*, one would have to insert an additional cast.

Should it compile?

2020-06-06 Thread Jack Applegame via Digitalmars-d-learn
Should it compile? ```d import std.algorithm.mutation; void main() { const char a = void; const char b ='b'; moveEmplace(b, a); // mutation.d: Error: cannot modify const expression target assert(a == 'b'); } ``` I think, it should.

Re: How debugg unittest with visual code + code-d

2020-06-06 Thread Andre Pany via Digitalmars-d-learn
On Saturday, 6 June 2020 at 08:06:02 UTC, Luis wrote: On Friday, 5 June 2020 at 18:13:52 UTC, WebFreak001 wrote: To build before running the debugger, add the following task to your task definitions file (Ctrl-Shift-B): { "label": "dub build", // <-- add a good name here

Re: How debugg unittest with visual code + code-d

2020-06-06 Thread WebFreak001 via Digitalmars-d-learn
On Saturday, 6 June 2020 at 08:06:02 UTC, Luis wrote: On Friday, 5 June 2020 at 18:13:52 UTC, WebFreak001 wrote: [...] It isn't working correctly on my case : I get this error : Performing "unittest" build using dmd for x86_64. ddiv ~sparseSet: building configuration "unittest"...

Re: Should it compile?

2020-06-06 Thread MoonlightSentinel via Digitalmars-d-learn
On Saturday, 6 June 2020 at 08:55:20 UTC, Jack Applegame wrote: Should it compile? No, moveEmplace just sees a const reference and doesn't know that a is void-initialized.

Metaprogramming with D

2020-06-06 Thread Jan Hönig via Digitalmars-d-learn
We have two (little) student projects, which should use D for meta-programming/code generation. More specifically string mixins and templates. I understand (at least I think so :)) string mixins. The task is to create a small internal DSL, which is capable of printing out D code, which we

Re: How debugg unittest with visual code + code-d

2020-06-06 Thread Luis via Digitalmars-d-learn
On Saturday, 6 June 2020 at 08:42:22 UTC, WebFreak001 wrote: On Saturday, 6 June 2020 at 08:06:02 UTC, Luis wrote: On Friday, 5 June 2020 at 18:13:52 UTC, WebFreak001 wrote: [...] It isn't working correctly on my case : I get this error : Performing "unittest" build using dmd for x86_64.

Re: Should it compile?

2020-06-06 Thread Basile B. via Digitalmars-d-learn
On Saturday, 6 June 2020 at 08:55:20 UTC, Jack Applegame wrote: Should it compile? ```d import std.algorithm.mutation; void main() { const char a = void; const char b ='b'; moveEmplace(b, a); // mutation.d: Error: cannot modify const expression target assert(a == 'b'); } ```

Use classes as keys in associative array

2020-06-06 Thread JN via Digitalmars-d-learn
Is it possible to use different class instances as keys for associative array, but compare them by the contents? I tried to override opEquals but it doesn't seem to work. Basically I'd like this code to work. I know structs would work but I can't use structs for this): import std.stdio;

Re: How to port C++ std::is_reference to D ?

2020-06-06 Thread Q. Schroll via Digitalmars-d-learn
On Wednesday, 13 May 2020 at 13:36:14 UTC, wjoe wrote: On Monday, 11 May 2020 at 19:08:09 UTC, Q. Schroll wrote: [...] 1. You can have variables ("data members") of reference type in structs. (They work like head-const pointers; if D had head-const or at least head-const pointers, those

Re: Use classes as keys in associative array

2020-06-06 Thread ag0aep6g via Digitalmars-d-learn
On Saturday, 6 June 2020 at 16:49:29 UTC, JN wrote: Is it possible to use different class instances as keys for associative array, but compare them by the contents? I tried to override opEquals but it doesn't seem to work. You also need toHash.

Re: Metaprogramming with D

2020-06-06 Thread mw via Digitalmars-d-learn
On Saturday, 6 June 2020 at 09:57:36 UTC, Jan Hönig wrote: We have two (little) student projects, which should use D for meta-programming/code generation. More specifically string mixins and templates. I found this doc:

Re: Metaprogramming with D

2020-06-06 Thread Ali Çehreli via Digitalmars-d-learn
On 6/6/20 5:03 PM, FunkyD wrote:> On Saturday, 6 June 2020 at 09:57:36 UTC, Jan Hönig wrote: > D is pretty good for meta-programming. For certain other things it is > terrible. I am glad I don't know enough about other technologies to feel that way. > String mixins simply mix in D code. It

Re: Metaprogramming with D

2020-06-06 Thread Don via Digitalmars-d-learn
On Sunday, 7 June 2020 at 00:45:37 UTC, Ali Çehreli wrote: False. And again, even if so, that's not because of D, but because of humans. Can you imagine a CTO, say, in Silicon Valley to have guts to bring D instead of C++? With C++, the CTO will never be blamed; but D, he or she can easily be

Re: Use classes as keys in associative array

2020-06-06 Thread ikod via Digitalmars-d-learn
On Saturday, 6 June 2020 at 20:31:36 UTC, ikod wrote: On Saturday, 6 June 2020 at 16:49:29 UTC, JN wrote: Is it possible to use different class instances as keys for associative array, but compare them by the contents? I tried to override opEquals but it doesn't seem to work. Basically I'd

Re: Use classes as keys in associative array

2020-06-06 Thread ikod via Digitalmars-d-learn
On Saturday, 6 June 2020 at 16:49:29 UTC, JN wrote: Is it possible to use different class instances as keys for associative array, but compare them by the contents? I tried to override opEquals but it doesn't seem to work. Basically I'd May be wrong, but probably you have to override opEquals

Re: Metaprogramming with D

2020-06-06 Thread FunkyD via Digitalmars-d-learn
On Saturday, 6 June 2020 at 09:57:36 UTC, Jan Hönig wrote: We have two (little) student projects, which should use D for meta-programming/code generation. More specifically string mixins and templates. I understand (at least I think so :)) string mixins. The task is to create a small