3 ms·
Your issues touch the Java side of Clojure which admittedly is not documented very well if at all. Currently you need to implement multiple Java interfaces to c
by chousuke 15y ago
Your issues touch the Java side of Clojure which admittedly is not documented very well if at all. Currently you need to implement multiple Java interfaces to completely customise behaviour (which is why Clojure tries to give you enough tools so you don't need to do it). I suspect that once some of the Java interfaces get replaced with Clojure protocols, things will get easier.
However, these are issues that rarely come up in idiomatic Clojure. Most of the time you don't need your own collection classes, or new types that work like functions. It is possible, but since it's a rare need, I'm not surprised the documentation on how to do it is indirect at best... deftype is probably the best tool if you need something low-level like that, or defrecord if you just want something that works like a map.
Your 'simple' question isn't exactly simple either. The famous ants simulation is a fair example of a concurrent application, but often the design depends on the sort of concurrency you need, and the simple question suddenly becomes much more difficult. More examples wouldn't hurt, of course.
- chc 15y agoI agree that the things I named aren't tasks of huge importance, and I hope it doesn't seem like nit-picking, but they were examples of the sort of thing I like to do when I'm first looking at a language. I like to play around with the features the language touts, to try to get a good feel for how it "thinks". The other option is just to start out writing unidiomatic nonsense that doesn't use any unique features of the language, and I feel like I'm teaching myself bad habits when I do that. Anyway, my point is, this is pretty much the state of the Clojure documentation right now: On Clojure.org: - List of features - Alphabetical list of functions stretching as far as the eye can see On ClojureDocs.org: - List of functions by namespace - Long list of functions by "category" - A cheatsheet consisting of the long list of functions by category with descriptions removed ClojureDocs is much better, but it still isn't enough to even implement a simple facsimile of hash-set or figure out how to start multiple threads in order to take advantage of all those swanky concurrency features. (The concurrency example is actually something practical I wanted to do. I have a slightly quirky bin-packing algorithm that I wanted to parallelize and I felt stumped staring at the list of functions. Finally I found a Stack Overflow post that said to just use Java's Thread.run with a Clojure function.)
- chousuke 15y agoYeah, currently Clojure sort of assumes that you know enough to fall back to the Java class library if you can't find something in clojure.core, threading being a good example. The documentation is mostly terse, but there is http://java.ociweb.com/mark/clojure/article.html http://java.ociweb.com/mark/clojure/article.html which is more tutorial-like; though it's probably getting a bit old by now.
- moomin 15y agoIdiomatic way to do it is usually to call "future".