Comments (8)
On a similar vein, I don't think Printer should extend Closeable either.....
from edn-java.
The question is a more general one: do we want to expose checked exceptions, or not? I'm not a great fan of them, actually. Initially Parser did not throw checked exceptions. This changed, when I eliminated my home-grown Input abstraction and just had Scanner work directly on instances of Reader (which throws checked exceptions).
As currently designd, Parser and Printer are like the rest of the IO classes: they throw checked IOExceptions and they are Closeable. This is ugly, but it is idiomatic (Java).
I'll give the alternative of wrapping IOExceptions in a (subclass of) EdnException a try on a private branch and see if I like it better.
from edn-java.
I'm so-so about checked exceptions themselves: they are annoying sometimes but in other cases can be useful when you want to really ensure that users handle important error cases.
I think the underlying issue here is that Parser and Printer shouldn't be depending on IO: this is "complecting" the concept of a parser / printer with an implementation detail (i.e. the use of readers / writers than may perform IO)
My view is that the API design would be better if we could abstract the interface away from the concrete implementation details. You could still have a Parser backed by a Reader as the default concrete implementation (perhaps this would any IOException in an EdnException), but the door would be open to other implementations.
from edn-java.
Yes your previous comment hits on exactly what's wrong with checked exceptions: they leak implementation details into the public interface. I'll see what can be done by returning to my original idea (of exposing only unchecked exceptions at the public APIs).
from edn-java.
One advantage of going the idiomatic route (IOException, Closeable) does occur to me: Parser and Printer should play nicely with Java-7's try-with-resources.
from edn-java.
Sure we want to work nicely with try-with-resources, but that doesn't mean that Parser and Printer need to expose that detail: it should be the caller's job to use try-with-resources on whatever Reader / Writer is passed to the factory function to initialise the Parser / Printer.
from edn-java.
I've pushed the branch topic/issue-11 which removes checked exceptions from the public APIs of Parser and Printer.
from edn-java.
see also follow up issues:
#14
#15
from edn-java.
Related Issues (20)
- Iterate over list recieved via get. HOT 1
- > and < symbols are not supported HOT 3
- Values returned by Parser should be Serializable by default HOT 1
- Comma character prints incorrectly HOT 3
- PrintingExamples are sensitive to hash ordering HOT 1
- Teach edn-java to read namespaced maps as per CLJ-1910 HOT 1
- Teach edn-java to optionally print namespaced maps as per CLJ-1910
- Duplicate map keys are parsed without error HOT 5
- Add Java 8 to test with Travis too. HOT 1
- QuickCheck to test? HOT 1
- mispelling, in the docs
- Version 1.0? HOT 1
- Reader flag to support unicode escapes in string literals HOT 14
- Support reading \uXXXX character literals HOT 1
- Review edn-format; compare to implementation HOT 1
- Support # embedded in symbol names HOT 1
- Clojure's edn-read allows unicode in names, should edn-java do the same?
- Fix broken GPG magic HOT 4
- Octal escapes in string and character literals? HOT 1
- 0.7.0 or 0.7.1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edn-java.