Re: Help with Win32: PostQuitMessage(0) doesn't post WM_QUIT apparently, because the message loop is not exited.

2021-08-12 Thread Mike Parker via Digitalmars-d-learn
On Friday, 13 August 2021 at 00:30:59 UTC, Ruby The Roobster wrote: When I run the program and close the window, the program still runs in background mode. I don't know why this happens nor how to fix it. Does anybody know what's going on? frame beat me to it, but it may well be that you

Re: Any UML generators for D code?

2021-08-12 Thread rikki cattermole via Digitalmars-d-learn
On 13/08/2021 9:40 AM, russhy wrote: also this but it's pretty old: https://github.com/rikkimax/Duml It was a neat idea duml of mine, but I wouldn't recommend going down the path of CTFE for this. Best to write a tool using dmd-fe instead.

Re: Help with Win32: PostQuitMessage(0) doesn't post WM_QUIT apparently, because the message loop is not exited.

2021-08-12 Thread frame via Digitalmars-d-learn
On Friday, 13 August 2021 at 00:30:59 UTC, Ruby The Roobster wrote: When I run the program and close the window, the program still runs in background mode. I don't know why this happens nor how to fix it. Does anybody know what's going on? AFAIK GetMessage() may return -1 if some error hap

Help with Win32: PostQuitMessage(0) doesn't post WM_QUIT apparently, because the message loop is not exited.

2021-08-12 Thread Ruby The Roobster via Digitalmars-d-learn
Here is the message loop: ```d while(GetMessage(&msg, hwnd,0,0)) { if(msg.message == WM_QUIT) break; TranslateMessage(&msg); DispatchMessage(&msg); } ``` The WndProc(LRESULT CALLBACK): ```d extern(Windows) LRESULT WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) nothrow

Re: Any UML generators for D code?

2021-08-12 Thread russhy via Digitalmars-d-learn
On Thursday, 12 August 2021 at 21:11:24 UTC, JN wrote: I'd like to see the relationships between my D classes in a graphical form. Is there any tool that supports that? found this: https://code.dlang.org/packages/depend also this but it's pretty old: https://github.com/rikkimax/Duml

Any UML generators for D code?

2021-08-12 Thread JN via Digitalmars-d-learn
I'd like to see the relationships between my D classes in a graphical form. Is there any tool that supports that?

Re: Unnable to join Discord

2021-08-12 Thread Tejas via Digitalmars-d-learn
On Thursday, 12 August 2021 at 18:11:20 UTC, nayy wrote: Hi I cannot seems to be able to join the discord server It gives me the following error: "unable to accept invit" Is the invitation link expired? https://dlang.org/community.html https://discord.gg/bMZk9Q4 I joined last week with the

Unnable to join Discord

2021-08-12 Thread nayy via Digitalmars-d-learn
Hi I cannot seems to be able to join the discord server It gives me the following error: "unable to accept invit" Is the invitation link expired? https://dlang.org/community.html https://discord.gg/bMZk9Q4

Re: Cannot catch exception in debug mode

2021-08-12 Thread frame via Digitalmars-d-learn
On Thursday, 12 August 2021 at 03:46:00 UTC, kinke wrote: @frame: Please file an issue. https://issues.dlang.org/show_bug.cgi?id=22205

Re: I do not understand copy constructors

2021-08-12 Thread Ali Çehreli via Digitalmars-d-learn
On 8/12/21 4:32 AM, Paul Backus wrote: > Qualifying the ctor as `inout` works fine I can see how a DConf Online presention is shaping up in your head. ;) http://dconf.org/2021/online/index.html We need a collective understanding of effective use of such fundamental concepts. Ali

Re: I do not understand copy constructors

2021-08-12 Thread Learner via Digitalmars-d-learn
On Thursday, 12 August 2021 at 16:12:39 UTC, Paul Backus wrote: On Thursday, 12 August 2021 at 15:39:40 UTC, Learner wrote: [...] You have forgotten to add a member variable of type `A` to your `B` struct. If you add one, you will see the following error message: [...] "implicit conversi

Re: I do not understand copy constructors

2021-08-12 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 12 August 2021 at 15:39:40 UTC, Learner wrote: It is not clear to me why the inout generated copy constructor of the B structure is not able to copy the A structure. struct A { int[] data; this(ref return scope A rhs){ /* body */ }

Re: I do not understand copy constructors

2021-08-12 Thread Learner via Digitalmars-d-learn
On Thursday, 12 August 2021 at 15:50:05 UTC, Tejas wrote: On Thursday, 12 August 2021 at 15:39:40 UTC, Learner wrote: On Thursday, 12 August 2021 at 14:57:16 UTC, Steven Schveighoffer wrote: [...] It is not clear to me why the inout generated copy constructor of the B structure is not able t

Re: I do not understand copy constructors

2021-08-12 Thread Tejas via Digitalmars-d-learn
On Thursday, 12 August 2021 at 15:39:40 UTC, Learner wrote: On Thursday, 12 August 2021 at 14:57:16 UTC, Steven Schveighoffer wrote: [...] It is not clear to me why the inout generated copy constructor of the B structure is not able to copy the A structure. [...] Why will copy constructor

Re: I do not understand copy constructors

2021-08-12 Thread Learner via Digitalmars-d-learn
On Thursday, 12 August 2021 at 14:57:16 UTC, Steven Schveighoffer wrote: On 8/12/21 10:08 AM, Learner wrote: On Thursday, 12 August 2021 at 13:56:17 UTC, Paul Backus wrote: On Thursday, 12 August 2021 at 12:10:49 UTC, Learner wrote: That worked fine, but the codebase is @safe: ```d cast from

Re: I do not understand copy constructors

2021-08-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/12/21 10:08 AM, Learner wrote: On Thursday, 12 August 2021 at 13:56:17 UTC, Paul Backus wrote: On Thursday, 12 August 2021 at 12:10:49 UTC, Learner wrote: That worked fine, but the codebase is @safe: ```d cast from `int[]` to `inout(int[])` not allowed in safe code ``` So copy construct

Re: I do not understand copy constructors

2021-08-12 Thread Learner via Digitalmars-d-learn
On Thursday, 12 August 2021 at 13:56:17 UTC, Paul Backus wrote: On Thursday, 12 August 2021 at 12:10:49 UTC, Learner wrote: That worked fine, but the codebase is @safe: ```d cast from `int[]` to `inout(int[])` not allowed in safe code ``` So copy constructors force me to introduce trusted met

Re: I do not understand copy constructors

2021-08-12 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 12 August 2021 at 12:10:49 UTC, Learner wrote: That worked fine, but the codebase is @safe: ```d cast from `int[]` to `inout(int[])` not allowed in safe code ``` So copy constructors force me to introduce trusted methods, while that was not necessary with postblits? A postblit

Re: I do not understand copy constructors

2021-08-12 Thread Tejas via Digitalmars-d-learn
On Thursday, 12 August 2021 at 12:28:32 UTC, Learner wrote: On Thursday, 12 August 2021 at 12:22:22 UTC, Tejas wrote: On Thursday, 12 August 2021 at 12:19:56 UTC, Tejas wrote: [...] Works with ```@safe``` as well Paul was just trying to make that other answer work, you don't have to make co

Re: I do not understand copy constructors

2021-08-12 Thread Tejas via Digitalmars-d-learn
On Thursday, 12 August 2021 at 12:22:22 UTC, Tejas wrote: On Thursday, 12 August 2021 at 12:19:56 UTC, Tejas wrote: [...] Works with ```@safe``` as well Paul was just trying to make that other answer work, you don't have to make copy constructors ```@trusted``` Ignore this, it doesn't wor

Re: I do not understand copy constructors

2021-08-12 Thread Learner via Digitalmars-d-learn
On Thursday, 12 August 2021 at 12:22:22 UTC, Tejas wrote: On Thursday, 12 August 2021 at 12:19:56 UTC, Tejas wrote: [...] Works with ```@safe``` as well Paul was just trying to make that other answer work, you don't have to make copy constructors ```@trusted``` Operations are needed on `ot

Re: I do not understand copy constructors

2021-08-12 Thread Tejas via Digitalmars-d-learn
On Thursday, 12 August 2021 at 12:19:56 UTC, Tejas wrote: On Thursday, 12 August 2021 at 11:54:22 UTC, Learner wrote: [...] Just add ```inout``` inside ```this(ref inout/*notice the inout*/ Foo other) inout/*notice the inout*/``` Example code: ```d struct Foo { this(ref inout Foo ot

Re: I do not understand copy constructors

2021-08-12 Thread Tejas via Digitalmars-d-learn
On Thursday, 12 August 2021 at 11:54:22 UTC, Learner wrote: On Thursday, 12 August 2021 at 10:10:17 UTC, rikki cattermole wrote: On 12/08/2021 9:36 PM, Learner wrote: It seems that there is no easy way to transition from a postblit to a copy constructor, no? struct Foo { this(ref Foo

Re: I do not understand copy constructors

2021-08-12 Thread Learner via Digitalmars-d-learn
On Thursday, 12 August 2021 at 11:32:03 UTC, Paul Backus wrote: On Thursday, 12 August 2021 at 11:19:34 UTC, drug wrote: ```D struct A { int[] data; this(ref return scope inout A rhs) /* no inout here */ { data = rhs.data.dup; } } ``` The problem is that if you qualify the ctor itself

Re: I do not understand copy constructors

2021-08-12 Thread Learner via Digitalmars-d-learn
On Thursday, 12 August 2021 at 11:07:24 UTC, drug wrote: 12.08.2021 12:36, Learner пишет: > It seems that there is no easy way to transition from a postblit to a copy constructor, no? You just need both const and mutable copy ctors to replace inout one: ```D struct A { int[] data;

Re: I do not understand copy constructors

2021-08-12 Thread drug via Digitalmars-d-learn
12.08.2021 14:32, Paul Backus пишет: This is not true. Qualifying the ctor as `inout` works fine: https://run.dlang.io/is/Kpzp5M The problem in this example is that `.dup` always returns a mutable array, even if the array being copied is `inout`. The solution is to cast the copy back to the

Re: I do not understand copy constructors

2021-08-12 Thread Learner via Digitalmars-d-learn
On Thursday, 12 August 2021 at 10:10:17 UTC, rikki cattermole wrote: On 12/08/2021 9:36 PM, Learner wrote: It seems that there is no easy way to transition from a postblit to a copy constructor, no? struct Foo { this(ref Foo other) { foreach(i, v; other.tupleof)

Re: I do not understand copy constructors

2021-08-12 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 12 August 2021 at 11:19:34 UTC, drug wrote: ```D struct A { int[] data; this(ref return scope inout A rhs) /* no inout here */ { data = rhs.data.dup; } } ``` The problem is that if you qualify the ctor itself then if you pass const/immutable rhs to it then the ctor is cons

Re: I do not understand copy constructors

2021-08-12 Thread drug via Digitalmars-d-learn
12.08.2021 14:07, drug пишет: 12.08.2021 12:36, Learner пишет:  > It seems that there is no easy way to transition from a postblit to a copy constructor, no? You just need both const and mutable copy ctors to replace inout one: ```D struct A {     int[] data;     this(ref return scope A

Re: I do not understand copy constructors

2021-08-12 Thread drug via Digitalmars-d-learn
12.08.2021 12:36, Learner пишет: > It seems that there is no easy way to transition from a postblit to a copy constructor, no? You just need both const and mutable copy ctors to replace inout one: ```D struct A { int[] data; this(ref return scope A rhs) { data = rhs.data.dup; }

Re: I do not understand copy constructors

2021-08-12 Thread rikki cattermole via Digitalmars-d-learn
On 12/08/2021 9:36 PM, Learner wrote: It seems that there is no easy way to transition from a postblit to a copy constructor, no? struct Foo { this(ref Foo other) { foreach(i, v; other.tupleof) this.tupleof[i] = v; } @disable th

Re: I do not understand copy constructors

2021-08-12 Thread Learner via Digitalmars-d-learn
On Thursday, 12 August 2021 at 09:14:02 UTC, Paul Backus wrote: On Thursday, 12 August 2021 at 08:42:27 UTC, Learner wrote: struct A { int[] data this(ref return scope A rhs) { data = ths.data.dup; } } Generating an `inout` copy constructor for `struct B` failed, th

Re: I do not understand copy constructors

2021-08-12 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 12 August 2021 at 08:42:27 UTC, Learner wrote: struct A { int[] data this(ref return scope A rhs) { data = ths.data.dup; } } Generating an `inout` copy constructor for `struct B` failed, therefore instances of it are uncopyable What is an `inout` copy

I do not understand copy constructors

2021-08-12 Thread Learner via Digitalmars-d-learn
I have a structure like, used by other structures: struct A { int[] data; this(this) { data = data.dup; } } I am trying to upgrade it to use copy constructor: struct A { int[] data this(ref return scope A rhs) { data = ths.data.dup; } } Gener