Live data from Hacker News

Introduction to Clojure

cio.com.au

21–23 of 23 posts

Re: Introduction to Clojure

#21

Earlier quoted context omitted.

> Throwing java.lang.Exception if a condition is not meat in your clojure functions? Don't do this either!!! What's the proper way of doing that in clojure ?

-way- is not the problem here. The java.lang.Exception is. :-) Throw specialized "Runtime Exceptions" would be the way to go. For example throw IllegalArgumentException runtime exception if function call receives inappropriate arguments. You can also define your own specific (app-level) exception by proxying the RuntimeException or other relevant using the clojure's proxy macro.

Ah right! Apologies, I took it to mean that there was a better way of throwing an exception, not that particular one.

Of course, that makes perfect sense.

Re: Introduction to Clojure

#23
post #9

Earlier quoted context omitted.

That's not much help when you want to close all but one or two. The solution is to use the right tool for the job. Emacs has something called paredit-mode that relieves you of having to type the closing parens.

Someone should make a really good course to 'bridge' from being an experienced PHP, Perl, Java or Python programmer to that same level of competence using Clojure.

From my experience, the syntactic gap is wider than the semantic one. I suggest first, perhaps, translating Python into faux S-exprs (should be easy, given the indentation style). From there one might emphasize declarative vs. imperative, and functional as a subset of the former.
Post reply on HN