Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #37774
| From | Patrick Roemer <sangamon@netcologne.de> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Two exceptions |
| Date | 2017-12-09 13:47 +0100 |
| Organization | news.netcologne.de |
| Message-ID | <p0gm14$bmr$1@newsreader4.netcologne.de> (permalink) |
| References | <p0f54o$n5f$1@gioia.aioe.org> <p0f6p8$256$1@dont-email.me> <p0f8pt$s13$1@gioia.aioe.org> |
Responding to Victor Porton: > The main reason I chose to use exceptions for this, is to allow parse() > method to return the result of parsing (not a boolean value). For example > result of parsing an integer may return "long". > > Can you propose another alternative? It is to be easily programmable (if I > find handling exceptions too slow, I always can rewrite my program). > > Oh, I see, you proposed to return "null" instead of my ParseException. It > however also seems to me not a quite good solution, because returning null > may be a non-exceptionable situation (as for a missing optional object in > the parsed resource). Instead of null, you could use (potentially nested) java.util.Optional for both, signaling failed parse attempts and optional productions. failure: empty success (plain): of(x) success (optional, non-match): of(empty) success (optional, match): of(of(x)) Preferably, you could introduce a specialized union type for the parse result, allowing you to propagate detail information in the failure case. See the Reply type here, for example: https://github.com/jon-hanson/parsecj#types Best regards, Patrick
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Two exceptions Victor Porton <porton@narod.ru> - 2017-12-09 00:53 +0200
Re: Two exceptions Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-12-08 18:21 -0500
Re: Two exceptions Victor Porton <porton@narod.ru> - 2017-12-09 01:55 +0200
Re: Two exceptions Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-12-09 07:39 -0500
Re: Two exceptions Victor Porton <porton@narod.ru> - 2017-12-10 02:39 +0200
Re: Two exceptions Victor Porton <porton@narod.ru> - 2017-12-10 02:46 +0200
Re: Two exceptions Kiwi User <martin@mydomain.invalid> - 2017-12-10 00:52 +0000
Re: Two exceptions Patrick Roemer <sangamon@netcologne.de> - 2017-12-09 13:47 +0100
Re: Two exceptions Arne Vajhøj <arne@vajhoej.dk> - 2017-12-08 18:49 -0500
Re: Two exceptions v_borchert@despammed.com (Volker Borchert) - 2017-12-09 07:53 +0000
Re: Two exceptions Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-12-09 14:55 -0500
Re: Two exceptions Patrick Roemer <sangamon@netcologne.de> - 2017-12-11 15:09 +0100
csiph-web