digitalmars.D - Standard exception hierarchy
- Leandro Lucarella (19/19) Mar 27 2007 Hi! I was looking for any information about how D exceptions are
- Alberto Bertogli (19/23) Mar 29 2007 I started to play with D last week and ran into this very quickly. I was
- kris (6/39) Mar 29 2007 Tango has an extended set of pre-defined exceptions for this reason, and...
- Leandro Lucarella (6/12) Mar 30 2007 But as long as Tango don't replace Phobos and become the official D
- Dan (2/4) Mar 30 2007 Yeah, it does. Write using the Tango library, and you have a standard e...
- Leandro Lucarella (9/15) Mar 30 2007 No, I mean, I download an standard D compiler and I don't get Tango, I
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
Mar 27 2007
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
Mar 29 2007
Alberto Bertogli wrote:On Tue, Mar 27, 2007 at 03:09:38PM -0300, Leandro Lucarella wrote: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 IllegalArgumentExceptionIs 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
Mar 29 2007
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 IllegalArgumentExceptionBut 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
Mar 30 2007
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?
Mar 30 2007
Dan escribió:Leandro Lucarella Wrote: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-5252But 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?
Mar 30 2007