Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
March 27, 2007 Standard exception hierarchy | ||||
---|---|---|---|---|
| ||||
Hi! I was looking for any information about how D exceptions are arranged and I couldn't find anything but this proposal: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=21456 Is there any standard D exception hierarchy? If not, I think it's a good time to have one, because D is getting popular and people will start making it's own exception hierarchy and that would be too hard to change if D gets a standard hierarchy later. I think there is a great experience on this on existing languages, and D first have to decide if it want to have a small set of exceptions (like C++[1] for example) or a little larger one (like Python[2] for example). I don't really care too much on which way D should take, but I think it should take one soon. [1] http://www.roguewave.com/support/docs/sourcepro/edition9-update1/html/stdlibref/exceptions.html [2] http://docs.python.org/lib/module-exceptions.html -- Leandro Lucarella Integratech S.A. 4571-5252 |
March 30, 2007 Re: Standard exception hierarchy | ||||
---|---|---|---|---|
| ||||
Posted in reply to Leandro Lucarella | On Tue, Mar 27, 2007 at 03:09:38PM -0300, Leandro Lucarella wrote: > Is there any standard D exception hierarchy? If not, I think it's a good time to have one, because D is getting popular and people will start making it's own exception hierarchy and that would be too hard to change if D gets a standard hierarchy later. I started to play with D last week and ran into this very quickly. I was writing bindings for some application I wrote (http://auriga.wearlab.de/~alb/nmdb/ is the app, you can browse the bindings at http://repo.or.cz/w/nmdb.git?a=tree;f=d) and I needed to raise an exception where a key in some kind of associative array was not found. I looked up to see the standard hierarchy only to found out there was none, which was a bit of a bummer (the biggest one so far, because D looks quite nice). Then I tried to use the same one used by the standard data type, but it required I give a file and a line number to it, which wasn't very clean either. Finally I had to implement my own, but it would have been much better to have some standard hierarchy to use, or at least to have as a "recommended style reference" for names and inheritance. Are there any plans to work on this? Thanks, Alberto |
March 30, 2007 Re: Standard exception hierarchy | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alberto Bertogli | Alberto Bertogli wrote:
> On Tue, Mar 27, 2007 at 03:09:38PM -0300, Leandro Lucarella wrote:
>
>>Is there any standard D exception hierarchy? If not, I think it's a good time to have one, because D is getting popular and people will start making it's own exception hierarchy and that would be too hard to change if D gets a standard hierarchy later.
>
>
> I started to play with D last week and ran into this very quickly. I was
> writing bindings for some application I wrote
> (http://auriga.wearlab.de/~alb/nmdb/ is the app, you can browse the
> bindings at http://repo.or.cz/w/nmdb.git?a=tree;f=d) and I needed to
> raise an exception where a key in some kind of associative array was not
> found.
>
> I looked up to see the standard hierarchy only to found out there was
> none, which was a bit of a bummer (the biggest one so far, because D
> looks quite nice).
>
> Then I tried to use the same one used by the standard data type, but it
> required I give a file and a line number to it, which wasn't very clean
> either.
>
> Finally I had to implement my own, but it would have been much better to
> have some standard hierarchy to use, or at least to have as a
> "recommended style reference" for names and inheritance.
>
> Are there any plans to work on this?
>
> Thanks,
> Alberto
>
>
Tango has an extended set of pre-defined exceptions for this reason, and they live in tango.core.Exception. You might find something there to meet your needs?
e.g. IllegalElementException, NoSuchElementException, and IllegalArgumentException
|
March 30, 2007 Re: Standard exception hierarchy | ||||
---|---|---|---|---|
| ||||
Posted in reply to kris | > Tango has an extended set of pre-defined exceptions for this reason, and they live in tango.core.Exception. You might find something there to meet your needs? > > e.g. IllegalElementException, NoSuchElementException, and IllegalArgumentException But as long as Tango don't replace Phobos and become the official D standard library, this solves nothing about an standard exception hierarchy. -- Leandro Lucarella Integratech S.A. 4571-5252 |
March 30, 2007 Re: Standard exception hierarchy | ||||
---|---|---|---|---|
| ||||
Posted in reply to Leandro Lucarella | Leandro Lucarella Wrote:
> But as long as Tango don't replace Phobos and become the official D standard library, this solves nothing about an standard exception hierarchy.
Yeah, it does. Write using the Tango library, and you have a standard exception hierarchy. Unless you mean standard - everyone and everyone has to use it?
|
March 30, 2007 Re: Standard exception hierarchy | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dan | Dan escribió: > Leandro Lucarella Wrote: > >> But as long as Tango don't replace Phobos and become the official D standard library, this solves nothing about an standard exception hierarchy. > > Yeah, it does. Write using the Tango library, and you have a standard exception hierarchy. Unless you mean standard - everyone and everyone has to use it? No, I mean, I download an standard D compiler and I don't get Tango, I have to put an external dependency on my software. Any other library could define it's own "standard" exception hierarchy, but that's not the idea. -- Leandro Lucarella Integratech S.A. 4571-5252 |
Copyright © 1999-2021 by the D Language Foundation