Re: On exceptions, errors, and contract violations

2014-10-29 Thread Bruno Medeiros via Digitalmars-d
On 03/10/2014 18:40, Sean Kelly wrote: I finally realized what's been bugging me about thew program logic error, airplane vs. server discussion, and rather than have it lost in the other thread I thought I'd start a new one. The actual problem driving these discussions is that the vocabulary

Re: On exceptions, errors, and contract violations

2014-10-29 Thread Sean Kelly via Digitalmars-d
On Wednesday, 29 October 2014 at 13:28:28 UTC, Bruno Medeiros wrote: Even if we could correctly differentiate between precondition failures and postcondition ones, what would that gives us of use? It would give us an idea of where to look for the bug. Also, it provides the option of

Re: On exceptions, errors, and contract violations

2014-10-06 Thread Marco Leise via Digitalmars-d
Ok, I get it. You are asking for a change in paradigms. But it is way outside my comfort zone to say yes or no to it. I will just go on duplicating the error checking through input validation. -- Marco

Re: On exceptions, errors, and contract violations

2014-10-06 Thread Steven Schveighoffer via Digitalmars-d
On 10/3/14 1:40 PM, Sean Kelly wrote: Setting aside exceptions for the moment, one thing I've realized about errors is that in most cases, an API has no idea how important its proper function is to the application writer. This is the thing I have been arguing. Inside a library, the idea of

Re: On exceptions, errors, and contract violations

2014-10-06 Thread via Digitalmars-d
On Monday, 6 October 2014 at 13:11:25 UTC, Marco Leise wrote: Ok, I get it. You are asking for a change in paradigms. But it is way outside my comfort zone to say yes or no to it. I will just go on duplicating the error checking through input validation. I think D, Go, Rust and C++ struggle

Re: On exceptions, errors, and contract violations

2014-10-06 Thread Jacob Carlborg via Digitalmars-d
On 2014-10-06 16:36, Steven Schveighoffer wrote: This is the thing I have been arguing. Inside a library, the idea of input to the function being user defined or program-defined is not clear. It means that any user-defined input has to be double checked in the same exact way, to avoid having an

Re: On exceptions, errors, and contract violations

2014-10-05 Thread Dicebot via Digitalmars-d
I agree with most parts and this pretty much fits my unhappy experience of trying to use D assert/contract system. However I don't feel like contracts and plain assertions should throw different kinds of exceptions - it allows to distinguish some cases but does not solve the problem in

Re: On exceptions, errors, and contract violations

2014-10-05 Thread Marco Leise via Digitalmars-d
Am Fri, 03 Oct 2014 19:46:15 + schrieb Ola Fosheim Grøstad ola.fosheim.grostad+dl...@gmail.com: You simply turn the logic error into a cannot compute this result if that is suitable for the application. And the programming language should not make this hard. I don't get this. When we

Re: On exceptions, errors, and contract violations

2014-10-05 Thread via Digitalmars-d
On Sunday, 5 October 2014 at 21:16:17 UTC, Marco Leise wrote: I don't get this. When we say logic error we are talking bugs in the program. By what definition? And what if I decide that I want my programs to recover from bugs in insignificant code sections and keep going? Is a type error

On exceptions, errors, and contract violations

2014-10-03 Thread Sean Kelly via Digitalmars-d
I finally realized what's been bugging me about thew program logic error, airplane vs. server discussion, and rather than have it lost in the other thread I thought I'd start a new one. The actual problem driving these discussions is that the vocabulary we're using to describe error

Re: On exceptions, errors, and contract violations

2014-10-03 Thread bearophile via Digitalmars-d
Sean Kelly: Another issue is what the error tells us about the locality of the failure. A precondition indicates that the failure simply occurred sometime before the precondition was called, while a postcondition indicates that the failure occurred within the processing of the function.

Re: On exceptions, errors, and contract violations

2014-10-03 Thread monarch_dodra via Digitalmars-d
On Friday, 3 October 2014 at 17:40:43 UTC, Sean Kelly wrote: A contract has preconditions and postconditions to validate different types of errors. Preconditions validate user input (caller error), and postconditions validate resulting state (callee error). Technically, a precondition

Re: On exceptions, errors, and contract violations

2014-10-03 Thread Sean Kelly via Digitalmars-d
On Friday, 3 October 2014 at 17:51:16 UTC, monarch_dodra wrote: Also, I don't think postconditions are meant to check callee errors. That's what asserts do. Rather, postconditions are verifications that can ony occur *after* the call. For example, a function that takes an input range (no

Re: On exceptions, errors, and contract violations

2014-10-03 Thread Ali Çehreli via Digitalmars-d
On 10/03/2014 10:40 AM, Sean Kelly wrote: an API has no idea how important its proper function is to the application writer. Agreed. Further, an API has no idea whether its caller is a user or a library. (I will expand below.) If a programmer passes out of range arguments to a

Re: On exceptions, errors, and contract violations

2014-10-03 Thread via Digitalmars-d
On Friday, 3 October 2014 at 17:40:43 UTC, Sean Kelly wrote: Setting aside exceptions for the moment, one thing I've realized about errors is that in most cases, an API has no idea how important its proper function is to the application writer. If a programmer passes out of range arguments to