Re: Any way to create derived classes from Exception with canned messages?

2021-07-31 Thread Adam D Ruppe via Digitalmars-d-learn
I'll add just for info sake even though you can just use normal gc in your own constructors as wanted, other options include: 1) making a buffer inside your new object and copying the message to it, then passing a slice of your buffer to the super ctor. 2) making all the messages

Re: Any way to create derived classes from Exception with canned messages?

2021-07-31 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 31 July 2021 at 08:25:56 UTC, Jeremy T. Gibson wrote: Now, https://github.com/dlang/druntime/blob/master/src/object.d clearly expresses that the constructors of Exception are @nogc. That doesn't mean your constructors have to be! You can do whatever you want. Constructors aren't

Re: Any way to create derived classes from Exception with canned messages?

2021-07-31 Thread jfondren via Digitalmars-d-learn
On Saturday, 31 July 2021 at 08:25:56 UTC, Jeremy T. Gibson wrote: Now, https://github.com/dlang/druntime/blob/master/src/object.d clearly expresses that the constructors of Exception are @nogc. Therein lies the problem: there is no way to use the ~ concatenation operator in a @nogc function.

Re: How to put an arbitrary string to clipboard in D?

2021-07-31 Thread rikki cattermole via Digitalmars-d-learn
On 01/08/2021 6:30 AM, tastyminerals wrote: So I thought there may be a way in D to communicate with the system clipboard... No, this requires a windowing library and yes a window to do it (depending on the windowing system and even the desktop environment).

Re: How to put an arbitrary string to clipboard in D?

2021-07-31 Thread tastyminerals via Digitalmars-d-learn
On Friday, 30 July 2021 at 20:01:09 UTC, rikki cattermole wrote: On 31/07/2021 7:33 AM, tastyminerals wrote: I made a GUI app using tkd library. I am reading the string from one of the app widgets and would like to put it into the clipboard. Does anyone have an idea how to copy a string to

Re: Exit before second main with -funittest

2021-07-31 Thread Ali Çehreli via Digitalmars-d-learn
On 7/30/21 7:48 PM, Brian TIffin wrote: > Found, find, C++ too hot for most to handle, so why? I rubbed shoulders with C++ people who would argue to the effect of "C++ was not meant to be for everyone." > And a deeper thanks, Ali, for the book. You're welcome. I am very happy when it is

Re: How to put an arbitrary string to clipboard in D?

2021-07-31 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 31 July 2021 at 18:30:47 UTC, tastyminerals wrote: So I thought there may be a way in D to communicate with the system clipboard... You can always call the same system functions from D that you'd use from C. This is the source to my simpledisplay.d library on its clipboard

Routing of AssertError messages

2021-07-31 Thread DLearner via Digitalmars-d-learn
Hi This may be due to Windows, not DMD. Please see code below (held in test.d): ``` void main() { import std.stdio; writeln("Test"); assert(false, "TestAssert"); } ``` ` dmd -i -run test.d ` results in both "Test" and the "TestAssert" string (and trace) being routed to screen. But

Re: Routing of AssertError messages

2021-07-31 Thread jfondren via Digitalmars-d-learn
On Saturday, 31 July 2021 at 12:03:49 UTC, DLearner wrote: Hi This may be due to Windows, not DMD. Please see code below (held in test.d): ``` void main() { import std.stdio; writeln("Test"); assert(false, "TestAssert"); } ``` ` dmd -i -run test.d ` results in both "Test" and the

Re: Any way to create derived classes from Exception with canned messages?

2021-07-31 Thread Jeremy T. Gibson via Digitalmars-d-learn
On Saturday, 31 July 2021 at 11:30:06 UTC, Adam D Ruppe wrote: On Saturday, 31 July 2021 at 08:25:56 UTC, Jeremy T. Gibson wrote: Now, https://github.com/dlang/druntime/blob/master/src/object.d clearly expresses that the constructors of Exception are @nogc. That doesn't mean your

Re: Why are class methods not allowed to call cons/destructors?

2021-07-31 Thread Tejas via Digitalmars-d-learn
On Saturday, 31 July 2021 at 13:57:40 UTC, kinke wrote: This is possible via: ``` __dtor(); super.__dtor(); ``` WHOO YEAH!!! THANK YOU SO MUCH :D

Re: Why are class methods not allowed to call cons/destructors?

2021-07-31 Thread kinke via Digitalmars-d-learn
This is possible via: ``` __dtor(); super.__dtor(); ```

Why are class methods not allowed to call cons/destructors?

2021-07-31 Thread Tejas via Digitalmars-d-learn
```d class A{ ~this(){} destructA(){ ~this() } } class B:A{ ~this(){} destructB(){ ~this(); ~super(); } } ``` This could allow ```@nogc``` crowd to run destructors without calling ```destroy```. Yes, derived to base conversion is still a thing and

Re: Why are class methods not allowed to call cons/destructors?

2021-07-31 Thread Tejas via Digitalmars-d-learn
On Saturday, 31 July 2021 at 13:34:25 UTC, user1234 wrote: On Saturday, 31 July 2021 at 13:12:21 UTC, Tejas wrote: ```d class A{ ~this(){} destructA(){ ~this() } } class B:A{ ~this(){} destructB(){ ~this(); ~super(); } } ``` This could allow

Any way to create derived classes from Exception with canned messages?

2021-07-31 Thread Jeremy T. Gibson via Digitalmars-d-learn
Is there any way to go about making derived Exception classes which produce a passed error message plus a hard-coded annotation string provided by the derived class, allowing me to use both a consistent error message suffix plus a programmer-specified error message? I'm running into a

Re: Routing of AssertError messages

2021-07-31 Thread Tejas via Digitalmars-d-learn
On Saturday, 31 July 2021 at 12:03:49 UTC, DLearner wrote: Hi This may be due to Windows, not DMD. Please see code below (held in test.d): ``` void main() { import std.stdio; writeln("Test"); assert(false, "TestAssert"); } ``` ` dmd -i -run test.d ` results in both "Test" and the

Re: Why are class methods not allowed to call cons/destructors?

2021-07-31 Thread kinke via Digitalmars-d-learn
On Saturday, 31 July 2021 at 13:59:46 UTC, Tejas wrote: On Saturday, 31 July 2021 at 13:57:40 UTC, kinke wrote: This is possible via: ``` __dtor(); super.__dtor(); ``` WHOO YEAH!!! THANK YOU SO MUCH :D Heh you're welcome. Note that you'll probably want `__xdtor()`, which also destructs

Re: Why are class methods not allowed to call cons/destructors?

2021-07-31 Thread user1234 via Digitalmars-d-learn
On Saturday, 31 July 2021 at 13:12:21 UTC, Tejas wrote: ```d class A{ ~this(){} destructA(){ ~this() } } class B:A{ ~this(){} destructB(){ ~this(); ~super(); } } ``` This could allow ```@nogc``` crowd to run destructors without calling

Re: Why are class methods not allowed to call cons/destructors?

2021-07-31 Thread Tejas via Digitalmars-d-learn
On Saturday, 31 July 2021 at 13:34:25 UTC, user1234 wrote: On Saturday, 31 July 2021 at 13:12:21 UTC, Tejas wrote: ```d class A{ ~this(){} destructA(){ ~this() } } class B:A{ ~this(){} destructB(){ ~this(); ~super(); } } ``` This could allow