Re: Assertions getting corrupted

2017-10-26 Thread Jonathan M Davis via Digitalmars-d
On Thursday, October 26, 2017 10:05:11 bauss via Digitalmars-d wrote: > If D really wants to succeed with such things, then we cannot > assume the program is in an invalid state. It must be up to the > developer themselves to figure out if it's in an invalid state or > not. We've been over this

Re: Assertions getting corrupted

2017-10-26 Thread bauss via Digitalmars-d
On Thursday, 26 October 2017 at 06:27:53 UTC, Jonathan M Davis wrote: On Thursday, October 26, 2017 09:04:56 Shachar Shemesh via Digitalmars-d wrote: ... Walter believes that it's worse to do cleanup when an Error is thrown than it is to not do cleanup, because the program is an unknown and

Re: Assertions getting corrupted

2017-10-26 Thread Jonathan M Davis via Digitalmars-d
On Thursday, October 26, 2017 11:15:52 Shachar Shemesh via Digitalmars-d wrote: > On 26/10/17 09:27, Jonathan M Davis wrote: > > since almost no one ever derives from Throwable, > > and I don't think it's really intended that anyone do so much as it is > > possible (and I'm not sure why you

Re: Assertions getting corrupted

2017-10-26 Thread Shachar Shemesh via Digitalmars-d
On 26/10/17 09:27, Jonathan M Davis wrote: since almost no one ever derives from Throwable, and I don't think it's really intended that anyone do so much as it is possible (and I'm not sure why you would) Here's where we're doing it. Our product will often have several fibers essentially

Re: Assertions getting corrupted

2017-10-26 Thread Shachar Shemesh via Digitalmars-d
On 26/10/17 09:32, Johan Engelen wrote: Destructors will have the same problem, right? It seems to me that the cause of the problem is that `assert` throws instead of aborting execution right there. -Johan And, indeed, my solution in the specific case that triggered this post was to switch

Re: Assertions getting corrupted

2017-10-26 Thread Johan Engelen via Digitalmars-d
On Thursday, 26 October 2017 at 06:04:56 UTC, Shachar Shemesh wrote: There's a fundamental problem with scope(exit) and scope(failure). Consider the following code: { a = allocate_something(); scope(exit) a.cleanup(); ... assert(a.nothingHorribleWentWrong); } Ideally, if that

Re: Assertions getting corrupted

2017-10-26 Thread Jonathan M Davis via Digitalmars-d
On Thursday, October 26, 2017 09:04:56 Shachar Shemesh via Digitalmars-d wrote: > I'm going to hate myself for suggesting this, but here goes. > > There's a fundamental problem with scope(exit) and scope(failure). > Consider the following code: > > { >a = allocate_something(); >

Assertions getting corrupted

2017-10-26 Thread Shachar Shemesh via Digitalmars-d
I'm going to hate myself for suggesting this, but here goes. There's a fundamental problem with scope(exit) and scope(failure). Consider the following code: { a = allocate_something(); scope(exit) a.cleanup(); ... assert(a.nothingHorribleWentWrong); } Ideally, if that assert fails,