Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-01 Thread Bruno Medeiros via Digitalmars-d
On 29/09/2014 20:28, Sean Kelly wrote: Checked exceptions are good in theory but they failed utterly in Java. I'm not interested in seeing them in D. That is the conventional theory, the established wisdom. But the more I become experienced with Java, over the years, I've become convinced oth

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-01 Thread Jeremy Powers via Digitalmars-d
On Wed, Oct 1, 2014 at 7:24 AM, Bruno Medeiros via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > > What has failed is not the concept of checked exceptions per se, but > mostly, the failure of Java programmers to use checked exceptions > effectively, and properly design their code around t

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-01 Thread Sean Kelly via Digitalmars-d
On Wednesday, 1 October 2014 at 22:42:27 UTC, Jeremy Powers via Digitalmars-d wrote: If you see "throws Exception" in java code chances are the code is broken, same as if you see "catch (Exception" - this tells you nothing about the exception that happened, and hence you can do nothing with it

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-01 Thread David Nadlinger via Digitalmars-d
On Wednesday, 1 October 2014 at 23:00:41 UTC, Sean Kelly wrote: ...while in Phobos, most of the subtyped exceptions were eliminated a while back in favor of just always throwing Exception. What are you referring to specifically? Compared to Tango, yes, Phobos might have a lot fewer concrete ex

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-01 Thread Andrei Alexandrescu via Digitalmars-d
On 10/1/14, 4:00 PM, Sean Kelly wrote: On Wednesday, 1 October 2014 at 22:42:27 UTC, Jeremy Powers via Digitalmars-d wrote: If you see "throws Exception" in java code chances are the code is broken, same as if you see "catch (Exception" - this tells you nothing about the exception that happened

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-01 Thread Jacob Carlborg via Digitalmars-d
On 02/10/14 01:19, David Nadlinger wrote: What are you referring to specifically? Compared to Tango, yes, Phobos might have a lot fewer concrete exception types. But I don't recall actually eliminating existing ones. It happens implicitly when using "enforce". By default it will throw an inst

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-01 Thread Jacob Carlborg via Digitalmars-d
On 02/10/14 01:19, Andrei Alexandrescu wrote: My recollection is that was only talked about. Anyhow, one thing is clear - as of now there are no clear idioms and successful techniques for handling errors with exceptions (including the use of subtyping). -- Andrei I think most error handling is

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-03 Thread David Nadlinger via Digitalmars-d
On Thursday, 2 October 2014 at 06:39:17 UTC, Jacob Carlborg wrote: On 02/10/14 01:19, David Nadlinger wrote: What are you referring to specifically? Compared to Tango, yes, Phobos might have a lot fewer concrete exception types. But I don't recall actually eliminating existing ones. It happe

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-03 Thread Jacob Carlborg via Digitalmars-d
On 2014-10-03 14:36, David Nadlinger wrote: you are saying that specific exceptions were replaced by enforce? I can't recall something like this happening. I have no idea about this but I know there are a lot of "enforce" in Phobos and it sees to be encouraged to use it. Would be really sad i

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-05 Thread Marco Leise via Digitalmars-d
Am Fri, 03 Oct 2014 21:35:01 +0200 schrieb Jacob Carlborg : > On 2014-10-03 14:36, David Nadlinger wrote: > > > you are saying that specific exceptions were replaced by enforce? I > > can't recall something like this happening. > > I have no idea about this but I know there are a lot of "enforce

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-05 Thread Andrei Alexandrescu via Digitalmars-d
On 10/5/14, 8:08 AM, Marco Leise wrote: Nice, finally someone who actually wants to discern Exception types. I'm always at a loss as to what warrants its own exception type. E.g. when looking at network protocols, would a 503 be a NetworkException, a HTTPException or a HTTPInternalServerErrorExce

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-05 Thread Jacob Carlborg via Digitalmars-d
On 2014-10-05 17:08, Marco Leise wrote: Nice, finally someone who actually wants to discern Exception types. I'm always at a loss as to what warrants its own exception type. Yeah, that can be quite difficult. In the end, if you have a good exception hierarchy I don't think it will hurt to hav

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-05 Thread Andrei Alexandrescu via Digitalmars-d
On 10/5/14, 8:56 AM, Jacob Carlborg wrote: I would like to have as specific exception type as possible. Also a nice hierarchy of exception when catching a specific exception is not interesting. Instead of just a FileException there could be FileNotFoundException, PermissionDeniedExcepton and so o

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-05 Thread Dicebot via Digitalmars-d
On Sunday, 5 October 2014 at 16:18:33 UTC, Andrei Alexandrescu wrote: On 10/5/14, 8:56 AM, Jacob Carlborg wrote: I would like to have as specific exception type as possible. Also a nice hierarchy of exception when catching a specific exception is not interesting. Instead of just a FileExceptio

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-05 Thread Walter Bright via Digitalmars-d
On 10/5/2014 9:18 AM, Andrei Alexandrescu wrote: Exceptions are all about centralized error handling. How, and how often, would you handle FileNotFoundException differently than PermissionDeniedException? You would handle it differently if there was extra data attached to that particular excep

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-05 Thread Dmitry Olshansky via Digitalmars-d
05-Oct-2014 20:18, Andrei Alexandrescu пишет: On 10/5/14, 8:56 AM, Jacob Carlborg wrote: I would like to have as specific exception type as possible. Also a nice hierarchy of exception when catching a specific exception is not interesting. Instead of just a FileException there could be FileNotFo

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-05 Thread Andrei Alexandrescu via Digitalmars-d
On 10/5/14, 2:27 PM, Walter Bright wrote: On 10/5/2014 9:18 AM, Andrei Alexandrescu wrote: Exceptions are all about centralized error handling. How, and how often, would you handle FileNotFoundException differently than PermissionDeniedException? You would handle it differently if there was ex

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-05 Thread Jacob Carlborg via Digitalmars-d
On 05/10/14 23:50, Dmitry Olshansky wrote: Seems like it should be possible to define multiple interfaces for exceptions, and then catch by that (and/or combinations of such). Each of interface would be interested in a particular property of exception. Then catching by: FileException with Perm

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-05 Thread Jacob Carlborg via Digitalmars-d
On 05/10/14 18:18, Andrei Alexandrescu wrote: Exceptions are all about centralized error handling. How, and how often, would you handle FileNotFoundException differently than PermissionDeniedException? Probably not that often. But I don't think it's up to "File" to decide that. I think "File"

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-05 Thread Dmitry Olshansky via Digitalmars-d
06-Oct-2014 10:33, Jacob Carlborg пишет: On 05/10/14 23:50, Dmitry Olshansky wrote: Seems like it should be possible to define multiple interfaces for exceptions, and then catch by that (and/or combinations of such). Each of interface would be interested in a particular property of exception.

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-06 Thread Andrei Alexandrescu via Digitalmars-d
On 10/5/14, 11:31 PM, Jacob Carlborg wrote: On 05/10/14 18:18, Andrei Alexandrescu wrote: Exceptions are all about centralized error handling. How, and how often, would you handle FileNotFoundException differently than PermissionDeniedException? Probably not that often. But I don't think it's

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-06 Thread Andrei Alexandrescu via Digitalmars-d
On 10/5/14, 11:39 PM, Dmitry Olshansky wrote: It's obvious to me that one hierarchy is way to limiting for exceptions, simply because there could be many ways to categorize the same set of error conditions. Well put. -- Andrei

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-06 Thread H. S. Teoh via Digitalmars-d
On Mon, Oct 06, 2014 at 06:46:31AM -0700, Andrei Alexandrescu via Digitalmars-d wrote: > On 10/5/14, 11:39 PM, Dmitry Olshansky wrote: > > > >It's obvious to me that one hierarchy is way to limiting for > >exceptions, simply because there could be many ways to categorize the > >same set of error c

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-06 Thread Andrei Alexandrescu via Digitalmars-d
On 10/6/14, 7:01 AM, H. S. Teoh via Digitalmars-d wrote: On Mon, Oct 06, 2014 at 06:46:31AM -0700, Andrei Alexandrescu via Digitalmars-d wrote: On 10/5/14, 11:39 PM, Dmitry Olshansky wrote: It's obvious to me that one hierarchy is way to limiting for exceptions, simply because there could be

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-06 Thread Jacob Carlborg via Digitalmars-d
On 06/10/14 15:45, Andrei Alexandrescu wrote: Knowledge doesn't have to be by type; just place data inside the exception. About the only place where multiple "catch" statements are used to make fine distinctions between exception types is in sample code showing how to use multiple "catch" statem

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-06 Thread Andrei Alexandrescu via Digitalmars-d
On 10/6/14, 7:48 AM, Jacob Carlborg wrote: On 06/10/14 15:45, Andrei Alexandrescu wrote: Knowledge doesn't have to be by type; just place data inside the exception. About the only place where multiple "catch" statements are used to make fine distinctions between exception types is in sample cod

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-06 Thread Regan Heath via Digitalmars-d
On Mon, 06 Oct 2014 15:48:31 +0100, Jacob Carlborg wrote: On 06/10/14 15:45, Andrei Alexandrescu wrote: Knowledge doesn't have to be by type; just place data inside the exception. About the only place where multiple "catch" statements are used to make fine distinctions between exception types

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-06 Thread Jacob Carlborg via Digitalmars-d
On 2014-10-06 17:07, Andrei Alexandrescu wrote: I don't. On the contrary, I do consider proliferating types to the multiplicity of possible errors an obvious design sin. -- Andrei You loose the ability to have exception specific data. And no, I don't want to see an associative array of Varian

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-06 Thread Jacob Carlborg via Digitalmars-d
On 2014-10-06 18:03, Regan Heath wrote: Why? It gives us the benefits of error code return values: - ability to easily/cheaply check for/compare them using "switch" on code value (vs comparing/casting types) - ability to pass through OS level codes directly Without any of the penalties:

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-06 Thread Andrei Alexandrescu via Digitalmars-d
Jacob Carlborg wrote: > On 2014-10-06 17:07, Andrei Alexandrescu wrote: > >> I don't. On the contrary, I do consider proliferating types to the >> multiplicity of possible errors an obvious design sin. -- Andrei > > You loose the ability to have exception specific data. And no, I don't > want to

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-06 Thread Andrei Alexandrescu via Digitalmars-d
On 10/6/14, 11:13 AM, Jacob Carlborg wrote: Then you'll always catch all exceptions. If error code doesn't match you need to rethrow the exception. Or make a language change that allows to catch based on the error code. Either solution is fine here because that's the rare case. -- Andrei

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-06 Thread Jeremy Powers via Digitalmars-d
On Mon, Oct 6, 2014 at 7:50 AM, Andrei Alexandrescu via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > On 10/6/14, 7:01 AM, H. S. Teoh via Digitalmars-d wrote: > >> On Mon, Oct 06, 2014 at 06:46:31AM -0700, Andrei Alexandrescu via >> Digitalmars-d wrote: >> >>> On 10/5/14, 11:39 PM, Dmitry

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-06 Thread Andrei Alexandrescu via Digitalmars-d
On 10/6/14, 4:46 PM, Jeremy Powers via Digitalmars-d wrote: On Mon, Oct 6, 2014 at 7:50 AM, Andrei Alexandrescu via Digitalmars-d I'm thinking a simple key-value store Variant[string] would accommodate any state needed for differentiating among exception kinds whenever that's necessar

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-06 Thread Jacob Carlborg via Digitalmars-d
On 06/10/14 20:26, Andrei Alexandrescu wrote: Then scope them. We already have scoping rules built in to the language. Why should we invent a new way and set of rules for this. -- /Jacob Carlborg

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-07 Thread Jeremy Powers via Digitalmars-d
On Mon, Oct 6, 2014 at 6:19 PM, Andrei Alexandrescu via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > On 10/6/14, 4:46 PM, Jeremy Powers via Digitalmars-d wrote: > >> On Mon, Oct 6, 2014 at 7:50 AM, Andrei Alexandrescu via Digitalmars-d >> I'm thinking a simple key-value store Variant[

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-07 Thread Jeremy Powers via Digitalmars-d
On Mon, Oct 6, 2014 at 6:19 PM, Andrei Alexandrescu via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > On 10/6/14, 4:46 PM, Jeremy Powers via Digitalmars-d wrote: > >> On Mon, Oct 6, 2014 at 7:50 AM, Andrei Alexandrescu via Digitalmars-d >> I'm thinking a simple key-value store Variant[

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-07 Thread H. S. Teoh via Digitalmars-d
On Tue, Oct 07, 2014 at 02:25:24PM -0700, Jeremy Powers via Digitalmars-d wrote: > On Mon, Oct 6, 2014 at 6:19 PM, Andrei Alexandrescu via Digitalmars-d < > digitalmars-d@puremagic.com> wrote: > > > On 10/6/14, 4:46 PM, Jeremy Powers via Digitalmars-d wrote: > > > >> On Mon, Oct 6, 2014 at 7:50 AM

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-07 Thread Jeremy Powers via Digitalmars-d
On Tue, Oct 7, 2014 at 3:44 PM, H. S. Teoh via Digitalmars-d < digitalmars-d@puremagic.com> wrote: [snip a bunch of stuff where we totally agree with each other] > Having said all that, though, an idea occurred to me. While it's > certainly true that the catch block must catch a *specific* type

Re: Program logic bugs vs input/environmental errors (checked exceptions)

2014-10-07 Thread H. S. Teoh via Digitalmars-d
On Tue, Oct 07, 2014 at 04:14:57PM -0700, Jeremy Powers via Digitalmars-d wrote: > On Tue, Oct 7, 2014 at 3:44 PM, H. S. Teoh via Digitalmars-d < > digitalmars-d@puremagic.com> wrote: [...] > > But what if we allow catch blocks to be "templated"? > > > > We could then introduce signature constraint