Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread Tejas via Digitalmars-d-learn
On Monday, 13 September 2021 at 18:42:47 UTC, Steven Schveighoffer wrote: On 9/13/21 1:54 PM, eugene wrote: [...] The GC only scans things that it knows about. Inside your EventQueue you have this code: [...] Umm is it okay that he declared variables `init` and `idle` of type `Stage`

Re: Development of the foundation of a programming language

2021-09-13 Thread Elronnd via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 03:24:45 UTC, max haughton wrote: On Tuesday, 14 September 2021 at 03:19:46 UTC, Elronnd wrote: On Monday, 13 September 2021 at 11:40:10 UTC, max haughton wrote: The dragon book barely mentions SSA for example In fairness, dmd doesn't use SSA either That's

Re: object.d: Error: module object is in file 'object.d' which cannot be read

2021-09-13 Thread max haughton via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 03:31:17 UTC, Kenneth Dallmann wrote: On Sunday, 27 March 2011 at 10:28:00 UTC, Ishan Thilina wrote: [...] I had the exact same problem, very frustrating. I believe I solved the issue, it was a simple error. When you are installing D, on Windows, it

Re: object.d: Error: module object is in file 'object.d' which cannot be read

2021-09-13 Thread Kenneth Dallmann via Digitalmars-d-learn
On Sunday, 27 March 2011 at 10:28:00 UTC, Ishan Thilina wrote: When I give "dmd untitled.d" command in my ubuntu maverick 64 bit laptop I get the following error. " object.d: Error: module object is in file 'object.d' which cannot be read import path[0] = /etc/../../src/phobos import path[1]

Re: Development of the foundation of a programming language

2021-09-13 Thread max haughton via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 03:19:46 UTC, Elronnd wrote: On Monday, 13 September 2021 at 11:40:10 UTC, max haughton wrote: The dragon book barely mentions SSA for example In fairness, dmd doesn't use SSA either That's not a good thing.

Re: Development of the foundation of a programming language

2021-09-13 Thread Elronnd via Digitalmars-d-learn
On Monday, 13 September 2021 at 11:40:10 UTC, max haughton wrote: The dragon book barely mentions SSA for example In fairness, dmd doesn't use SSA either

Recommendations on parsing XML via an InputRange

2021-09-13 Thread Chris Piker via Digitalmars-d-learn
Hi D I just finished a ~1K line project using `dxml` as the XML reader for my data streams. It works well in my test examples using memory mapped files, but like an impulse shopper I didn't notice that dxml requires `ForwardRange` objects. That's unfortunate, because my next enhancement

Re: Development of the foundation of a programming language

2021-09-13 Thread leikang via Digitalmars-d-learn
On Monday, 13 September 2021 at 10:23:14 UTC, Dennis wrote: On Monday, 13 September 2021 at 03:21:37 UTC, leikang wrote: Are there any recommended books or videos to learn about the principles of compilation? What else should I learn besides the principles of compilation? Check out this

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread eugene via Digitalmars-d-learn
On Monday, 13 September 2021 at 18:45:22 UTC, jfondren wrote: Instead of using a temporary EpollEvent array in EventQueue.wait, you could make the array an instance variable and have registerEventSource populate it directly Actually, initial version of all that was using array, allocated in

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread eugene via Digitalmars-d-learn
On Monday, 13 September 2021 at 18:42:47 UTC, Steven Schveighoffer wrote: And you are registering your signals using the `+=` operator. That was a sort of exercise with operator overloading. Now, with your stopper code that you showed, it looks like you are storing the reference to stopper

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread jfondren via Digitalmars-d-learn
On Monday, 13 September 2021 at 17:18:30 UTC, eugene wrote: Then after pressing ^C (SIGINT) the program gets SIGSEGV, since references to sg0 and sg1 are no longer valid (they are "sitting" in epoll_event structure). engine/ecap.d(54): Error: field `EpollEvent.es` cannot assign to misaligned

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/13/21 1:54 PM, eugene wrote: On Monday, 13 September 2021 at 17:40:41 UTC, user1234 wrote: The problems seems to lies in `newSignal()` which "would" not allocate using the GC.     final Signal newSignal(int signum) {     Signal sg = new Signal(signum);     sg.owner = this;    

Re: Which operators cannot be overloaded and why not?

2021-09-13 Thread NonNull via Digitalmars-d-learn
On Monday, 13 September 2021 at 16:12:34 UTC, H. S. Teoh wrote: On Mon, Sep 13, 2021 at 02:12:36PM +, NonNull via Digitalmars-d-learn wrote: Which operators cannot be overloaded and why not? Others have already given the list, so I won't repeat that. I didn't see unary &. Maybe others

Re: Which operators cannot be overloaded and why not?

2021-09-13 Thread user1234 via Digitalmars-d-learn
On Monday, 13 September 2021 at 18:06:42 UTC, NonNull wrote: On Monday, 13 September 2021 at 14:42:42 UTC, jfondren wrote: On Monday, 13 September 2021 at 14:33:03 UTC, user1234 wrote: - condition al expression ` cond ? exp : exp ` And many other boolean operators, unary !, binary && and ||

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread eugene via Digitalmars-d-learn
On Monday, 13 September 2021 at 17:56:34 UTC, user1234 wrote: thx, so the problem is not what I suspected to be (mixed gc-managed and manually managed memory). sorrry... I am actually C coder and do not have much experience with GC languages, so I did not even attempt to try use D without GC

Re: Which operators cannot be overloaded and why not?

2021-09-13 Thread NonNull via Digitalmars-d-learn
On Monday, 13 September 2021 at 14:42:42 UTC, jfondren wrote: On Monday, 13 September 2021 at 14:33:03 UTC, user1234 wrote: - condition al expression ` cond ? exp : exp ` And many other boolean operators, unary !, binary && and || https://dlang.org/spec/operatoroverloading.html lists all the

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread eugene via Digitalmars-d-learn
On Monday, 13 September 2021 at 17:18:30 UTC, eugene wrote: And the most strange thing is this It is echo-server/echo-client pair. And it is echo-client that crashes upon SIGINT. echo-server contains very similar code class Listener : StageMachine { enum ulong M0_WORK = 0; enum

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread user1234 via Digitalmars-d-learn
On Monday, 13 September 2021 at 17:54:43 UTC, eugene wrote: On Monday, 13 September 2021 at 17:40:41 UTC, user1234 wrote: The problems seems to lies in `newSignal()` which "would" not allocate using the GC. final Signal newSignal(int signum) { Signal sg = new Signal(signum);

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread eugene via Digitalmars-d-learn
On Monday, 13 September 2021 at 17:40:41 UTC, user1234 wrote: The problems seems to lies in `newSignal()` which "would" not allocate using the GC. final Signal newSignal(int signum) { Signal sg = new Signal(signum); sg.owner = this; sg.number = sg_number++;

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread user1234 via Digitalmars-d-learn
On Monday, 13 September 2021 at 17:18:30 UTC, eugene wrote: [...] At first glance and given the fact that some code necessary to diagnose the problem accurately is missing: `new Stopper` allocates using the GC. it's then a "GC range", it's content will be scanned and handled by the GC,

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread user1234 via Digitalmars-d-learn
On Monday, 13 September 2021 at 17:40:41 UTC, user1234 wrote: On Monday, 13 September 2021 at 17:18:30 UTC, eugene wrote: [...] At first glance and given the fact that some code necessary to diagnose the problem accurately is missing: `new Stopper` allocates using the GC. it's then a "GC

Program crash: GC destroys an object unexpectedly

2021-09-13 Thread eugene via Digitalmars-d-learn
Code snippets ```d class Stopper : StageMachine { enum ulong M0_IDLE = 0; Signal sg0, sg1; this() { super("STOPPER"); Stage init, idle; init = addStage("INIT", ); idle = addStage("IDLE", ); init.addReflex("M0", idle);

Re: Which operators cannot be overloaded and why not?

2021-09-13 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Sep 13, 2021 at 02:12:36PM +, NonNull via Digitalmars-d-learn wrote: > Which operators cannot be overloaded and why not? Others have already given the list, so I won't repeat that. As to the "why": In general, D tries to avoid the wild wild west, every operator for himself situation

Re: Which operators cannot be overloaded and why not?

2021-09-13 Thread user1234 via Digitalmars-d-learn
On Monday, 13 September 2021 at 14:59:38 UTC, Paul Backus wrote: On Monday, 13 September 2021 at 14:42:42 UTC, jfondren wrote: On Monday, 13 September 2021 at 14:33:03 UTC, user1234 wrote: - condition al expression ` cond ? exp : exp ` And many other boolean operators, unary !, binary && and

Re: Which operators cannot be overloaded and why not?

2021-09-13 Thread user1234 via Digitalmars-d-learn
On Monday, 13 September 2021 at 15:29:05 UTC, user1234 wrote: [...] so this is a bit like the postincr case. i.e "prevent the semantics to be hijacked".

Re: Which operators cannot be overloaded and why not?

2021-09-13 Thread user1234 via Digitalmars-d-learn
On Monday, 13 September 2021 at 14:42:42 UTC, jfondren wrote: On Monday, 13 September 2021 at 14:33:03 UTC, user1234 wrote: - condition al expression ` cond ? exp : exp ` And many other boolean operators, unary !, binary && and || They are all indirectly supported if `opCast` is overloaded:

Re: Which operators cannot be overloaded and why not?

2021-09-13 Thread Basile B. via Digitalmars-d-learn
On Monday, 13 September 2021 at 14:42:42 UTC, jfondren wrote: On Monday, 13 September 2021 at 14:33:03 UTC, user1234 wrote: - condition al expression ` cond ? exp : exp ` And many other boolean operators, unary !, binary && and || https://dlang.org/spec/operatoroverloading.html lists all the

Re: Which operators cannot be overloaded and why not?

2021-09-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/13/21 10:47 AM, user1234 wrote: On Monday, 13 September 2021 at 14:33:03 UTC, user1234 wrote: what else ? when you have ```d alias AA1 = int[int]; alias AA2 = AA1[int]; ``` then you can write ```d AA2 aa; aa[0] = [0 : 0]; aa[0][0] = 0; ``` The `[0][0]` cannot be expressed using

Re: Which operators cannot be overloaded and why not?

2021-09-13 Thread Paul Backus via Digitalmars-d-learn
On Monday, 13 September 2021 at 14:42:42 UTC, jfondren wrote: On Monday, 13 September 2021 at 14:33:03 UTC, user1234 wrote: - condition al expression ` cond ? exp : exp ` And many other boolean operators, unary !, binary && and || https://dlang.org/spec/operatoroverloading.html lists all the

Re: Which operators cannot be overloaded and why not?

2021-09-13 Thread user1234 via Digitalmars-d-learn
On Monday, 13 September 2021 at 14:33:03 UTC, user1234 wrote: what else ? when you have ```d alias AA1 = int[int]; alias AA2 = AA1[int]; ``` then you can write ```d AA2 aa; aa[0] = [0 : 0]; aa[0][0] = 0; ``` The `[0][0]` cannot be expressed using operator overloads (and a custom map type

Re: Which operators cannot be overloaded and why not?

2021-09-13 Thread jfondren via Digitalmars-d-learn
On Monday, 13 September 2021 at 14:33:03 UTC, user1234 wrote: - condition al expression ` cond ? exp : exp ` And many other boolean operators, unary !, binary && and || https://dlang.org/spec/operatoroverloading.html lists all the overloadable operators, and

Re: Which operators cannot be overloaded and why not?

2021-09-13 Thread user1234 via Digitalmars-d-learn
On Monday, 13 September 2021 at 14:12:36 UTC, NonNull wrote: Which operators cannot be overloaded and why not? Let's start the list. - `new` and `delete` Because operators are overloaded in aggregates new was supported but not anymore, the idea is that a an aggregate should not be tied a

Which operators cannot be overloaded and why not?

2021-09-13 Thread NonNull via Digitalmars-d-learn
Which operators cannot be overloaded and why not?

Re: Development of the foundation of a programming language

2021-09-13 Thread Paul Backus via Digitalmars-d-learn
On Monday, 13 September 2021 at 00:53:06 UTC, leikang wrote: I want to contribute to the development of the dlang language, but I feel that I am insufficient, so I want to ask the big guys, can I participate in the development of the Dlang language after learning the principles of compilation?

Re: Development of the foundation of a programming language

2021-09-13 Thread max haughton via Digitalmars-d-learn
On Monday, 13 September 2021 at 04:08:53 UTC, rikki cattermole wrote: On 13/09/2021 3:21 PM, leikang wrote: Are there any recommended books or videos to learn about the principles of compilation? What else should I learn besides the principles of compilation? The classic book on compilers

Re: Development of the foundation of a programming language

2021-09-13 Thread Dennis via Digitalmars-d-learn
On Monday, 13 September 2021 at 03:21:37 UTC, leikang wrote: Are there any recommended books or videos to learn about the principles of compilation? What else should I learn besides the principles of compilation? Check out this video: [DConf 2016 Day 2 Keynote: Spelunking D Compiler