Re: Truly @nogc Exceptions?

2018-10-21 Thread welkam via Digitalmars-d
On Thursday, 20 September 2018 at 10:48:35 UTC, Atila Neves wrote: What's the fix? Have the compiler insert a call to the exception's destructor at the end of the `catch(scope Exception)` block. If I understood you correctly then we have same idea. If exception is not handled or re thrown

Re: Truly @nogc Exceptions?

2018-10-20 Thread Paolo Invernizzi via Digitalmars-d
On Saturday, 20 October 2018 at 14:56:37 UTC, Mike Parker wrote: On Saturday, 20 October 2018 at 13:48:32 UTC, Paolo Invernizzi wrote: If `@nogc` could be relaxed for `new Error` exactly for that reason, pieces of Phobos could be turned `@nogc`... But I admit that that change would be

Re: Truly @nogc Exceptions?

2018-10-20 Thread Mike Parker via Digitalmars-d
On Saturday, 20 October 2018 at 13:48:32 UTC, Paolo Invernizzi wrote: If `@nogc` could be relaxed for `new Error` exactly for that reason, pieces of Phobos could be turned `@nogc`... But I admit that that change would be controversial...

Re: Truly @nogc Exceptions?

2018-10-20 Thread Paolo Invernizzi via Digitalmars-d
On Thursday, 20 September 2018 at 17:14:12 UTC, Steven Schveighoffer wrote: On 9/20/18 12:24 PM, Adam D. Ruppe wrote: On Thursday, 20 September 2018 at 15:52:03 UTC, Steven Schveighoffer wrote: I needed to know what the slice parameters that were failing were. Aye. Note that RangeError is

Re: Truly @nogc Exceptions?

2018-10-19 Thread Atila Neves via Digitalmars-d
On Friday, 19 October 2018 at 23:46:29 UTC, Nicholas Wilson wrote: On Friday, 19 October 2018 at 23:34:01 UTC, Atila Neves wrote: On Thursday, 20 September 2018 at 12:48:13 UTC, Steven Schveighoffer wrote: How is the exception destroyed when dip1008 is enabled? Apparently, it isn't. Which

Re: Truly @nogc Exceptions?

2018-10-19 Thread Nicholas Wilson via Digitalmars-d
On Friday, 19 October 2018 at 23:34:01 UTC, Atila Neves wrote: On Thursday, 20 September 2018 at 12:48:13 UTC, Steven Schveighoffer wrote: How is the exception destroyed when dip1008 is enabled? Apparently, it isn't. Which renders dip1008 pretty much useless since we could already use static

Re: Truly @nogc Exceptions?

2018-10-19 Thread Atila Neves via Digitalmars-d
On Thursday, 20 September 2018 at 12:48:13 UTC, Steven Schveighoffer wrote: On 9/20/18 6:48 AM, Atila Neves wrote: On Wednesday, 19 September 2018 at 21:16:00 UTC, Steven Schveighoffer wrote: Given dip1008, we now can throw exceptions inside @nogc code! This is really cool, and helps make code

Re: Truly @nogc Exceptions?

2018-09-21 Thread Petar via Digitalmars-d
On Friday, 21 September 2018 at 11:48:50 UTC, Nemanja Boric wrote: On Friday, 21 September 2018 at 10:06:06 UTC, Nemanja Boric wrote: On Friday, 21 September 2018 at 09:10:06 UTC, Jonathan M Davis wrote: [...] The @__future is fully (to a reasonable degree) implemented - and the

Re: Truly @nogc Exceptions?

2018-09-21 Thread Nemanja Boric via Digitalmars-d
On Friday, 21 September 2018 at 10:06:06 UTC, Nemanja Boric wrote: On Friday, 21 September 2018 at 09:10:06 UTC, Jonathan M Davis wrote: [...] The @__future is fully (to a reasonable degree) implemented - and the `Throwable.message` was marked with this attribute to prevent breaking the

Re: Truly @nogc Exceptions?

2018-09-21 Thread Nemanja Boric via Digitalmars-d
On Friday, 21 September 2018 at 09:10:06 UTC, Jonathan M Davis wrote: [...] I think that the message member was added by Dicebot as an attempt to fix this issue, because Sociomantic needed it, but I don't know exactly what's going on with that or @__future. - Jonathan M Davis The @__future

Re: Truly @nogc Exceptions?

2018-09-21 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, September 19, 2018 3:16:00 PM MDT Steven Schveighoffer via Digitalmars-d wrote: > Given dip1008, we now can throw exceptions inside @nogc code! This is > really cool, and helps make code that uses exceptions or errors @nogc. > Except... I pointed out this problem when the DIP was

Re: Truly @nogc Exceptions?

2018-09-20 Thread Steven Schveighoffer via Digitalmars-d
On 9/20/18 1:58 PM, Adam D. Ruppe wrote: On Thursday, 20 September 2018 at 17:14:12 UTC, Steven Schveighoffer wrote: I don't know how a performance problem can occur on an error being thrown anyway -- the process is about to end. Walter's objection was code size - it would throw stuff out of

Re: Truly @nogc Exceptions?

2018-09-20 Thread Neia Neutuladh via Digitalmars-d
On Thursday, 20 September 2018 at 15:52:15 UTC, H. S. Teoh wrote: Yeah, that's what I meant. :D Well, for backward compatibility we could still have .msg allocate and return a string, but we could provide an overload / alternate member function that writes directly to a sink instead. Then we

Re: Truly @nogc Exceptions?

2018-09-20 Thread Adam D. Ruppe via Digitalmars-d
On Thursday, 20 September 2018 at 17:14:12 UTC, Steven Schveighoffer wrote: I don't know how a performance problem can occur on an error being thrown anyway -- the process is about to end. Walter's objection was code size - it would throw stuff out of cache lines, even if it doesn't need to

Re: Truly @nogc Exceptions?

2018-09-20 Thread Steven Schveighoffer via Digitalmars-d
On 9/20/18 12:24 PM, Adam D. Ruppe wrote: On Thursday, 20 September 2018 at 15:52:03 UTC, Steven Schveighoffer wrote: I needed to know what the slice parameters that were failing were. Aye. Note that RangeError is called by the compiler though, so you gotta patch dmd to make it pass the

Re: Truly @nogc Exceptions?

2018-09-20 Thread Adam D. Ruppe via Digitalmars-d
On Thursday, 20 September 2018 at 15:52:03 UTC, Steven Schveighoffer wrote: I needed to know what the slice parameters that were failing were. Aye. Note that RangeError is called by the compiler though, so you gotta patch dmd to make it pass the arguments to it for index. Ugh. I did a PR for

Re: Truly @nogc Exceptions?

2018-09-20 Thread Steven Schveighoffer via Digitalmars-d
On 9/20/18 11:33 AM, Adam D. Ruppe wrote: On Wednesday, 19 September 2018 at 21:16:00 UTC, Steven Schveighoffer wrote: As Andrei says -- Destroy! Nah, I agree. Actually, I'm of the opinion that string error messages in exceptions ought to be considered harmful: you shouldn't be doing

Re: Truly @nogc Exceptions?

2018-09-20 Thread H. S. Teoh via Digitalmars-d
On Thu, Sep 20, 2018 at 11:25:27AM -0400, Steven Schveighoffer via Digitalmars-d wrote: > On 9/20/18 11:06 AM, H. S. Teoh wrote: [...] > > IIRC, originally the stacktrace was also built at exception > > construction time. But it was causing a major performance hit, so > > eventually someone

Re: Truly @nogc Exceptions?

2018-09-20 Thread Adam D. Ruppe via Digitalmars-d
On Wednesday, 19 September 2018 at 21:16:00 UTC, Steven Schveighoffer wrote: As Andrei says -- Destroy! Nah, I agree. Actually, I'm of the opinion that string error messages in exceptions ought to be considered harmful: you shouldn't be doing strings at all. All the useful information

Re: Truly @nogc Exceptions?

2018-09-20 Thread Steven Schveighoffer via Digitalmars-d
On 9/20/18 11:06 AM, H. S. Teoh wrote: On Thu, Sep 20, 2018 at 08:48:13AM -0400, Steven Schveighoffer via Digitalmars-d wrote: [...] But this means you still have to build msg when throwing the error/exception. It's not needed until you print it, and there's no reason anyway to make it

Re: Truly @nogc Exceptions?

2018-09-20 Thread H. S. Teoh via Digitalmars-d
On Thu, Sep 20, 2018 at 08:48:13AM -0400, Steven Schveighoffer via Digitalmars-d wrote: [...] > But this means you still have to build msg when throwing the > error/exception. It's not needed until you print it, and there's no > reason anyway to make it allocate, even with RAII. For some reason D

Re: Truly @nogc Exceptions?

2018-09-20 Thread Atila Neves via Digitalmars-d
On Thursday, 20 September 2018 at 12:48:13 UTC, Steven Schveighoffer wrote: On 9/20/18 6:48 AM, Atila Neves wrote: On Wednesday, 19 September 2018 at 21:16:00 UTC, Steven Schveighoffer wrote: [...] I expressed my concern for DIP1008 and the `msg` field when it was first announced. I think

Re: Truly @nogc Exceptions?

2018-09-20 Thread Steven Schveighoffer via Digitalmars-d
On 9/20/18 6:48 AM, Atila Neves wrote: On Wednesday, 19 September 2018 at 21:16:00 UTC, Steven Schveighoffer wrote: Given dip1008, we now can throw exceptions inside @nogc code! This is really cool, and helps make code that uses exceptions or errors @nogc. Except... The mechanism to report

Re: Truly @nogc Exceptions?

2018-09-20 Thread Atila Neves via Digitalmars-d
On Wednesday, 19 September 2018 at 21:16:00 UTC, Steven Schveighoffer wrote: Given dip1008, we now can throw exceptions inside @nogc code! This is really cool, and helps make code that uses exceptions or errors @nogc. Except... The mechanism to report what actually went wrong for an

Re: Truly @nogc Exceptions?

2018-09-19 Thread Steven Schveighoffer via Digitalmars-d
On 9/19/18 7:53 PM, Seb wrote: On Wednesday, 19 September 2018 at 21:28:56 UTC, Steven Schveighoffer wrote: On 9/19/18 5:16 PM, Steven Schveighoffer wrote: One further thing: I didn't make the sink version of message @nogc, but in actuality, it could be. We recently introduced support for

Re: Truly @nogc Exceptions?

2018-09-19 Thread Seb via Digitalmars-d
On Wednesday, 19 September 2018 at 21:28:56 UTC, Steven Schveighoffer wrote: On 9/19/18 5:16 PM, Steven Schveighoffer wrote: One further thing: I didn't make the sink version of message @nogc, but in actuality, it could be. We recently introduced support for output ranges in the formatting

Re: Truly @nogc Exceptions?

2018-09-19 Thread Steven Schveighoffer via Digitalmars-d
On 9/19/18 5:16 PM, Steven Schveighoffer wrote: One further thing: I didn't make the sink version of message @nogc, but in actuality, it could be. Notice how it allocates using the stack. Even if we needed some indeterminate amount of memory, it would be simple to use C malloc/free, or alloca.

Truly @nogc Exceptions?

2018-09-19 Thread Steven Schveighoffer via Digitalmars-d
Given dip1008, we now can throw exceptions inside @nogc code! This is really cool, and helps make code that uses exceptions or errors @nogc. Except... The mechanism to report what actually went wrong for an exception is a string passed to the exception during *construction*. Given that you