News for hackers. Stuff that matters.
Re:A Year of Clojure by zck on Friday December 31, 2010 @11:41AM (#2055732)
>What macros? I’m a bit embarrassed to say I’ve not yet written a single macro. Partially I tend to think the function version should exist regardless in most cases and partly I work with three other Clojure gurus that can satisfy my macro whims faster than I can state the need. Let’s call it a goal for 2011.

Heh, he hasn't completely grokked macros yet; they should only be written if the goal couldn't be done as a function.

Re:A Year of Clojure by thurn on Friday December 31, 2010 @12:40PM (#2055886)
Or, perhaps, if it gets you nicer syntax. The classic macro example "unless" could be written with a function, but then you'd need to write

(unless (< 1 2) #(println "hi"))

every time.

Re:A Year of Clojure by zck on Friday December 31, 2010 @12:46PM (#2055903)
Arguably, that's not the same, as long as you define "unless" as not having the hash there.

I'm not quite familiar with the hash -- is that just making a vector with println "hi" as its elements? How does the unless work with multiple statments? I'm sure you know that unless has an implicit progn in it -- does this? What's the code to implement this? I tried, but couldn't really figure out what to do with the vector.

Re:A Year of Clojure by ataggart on Friday December 31, 2010 @01:21PM (#2055987)
The hash is the anonymous function form. In the example, presumably the unless function calls and returns the value of the passed-in function when the test is logical true, otherwise returns nil.
Re:A Year of Clojure by zck on Friday December 31, 2010 @01:24PM (#2055999)
Ah, interesting. At least in clisp -- the Lisp I fired up to test this -- the hash is syntax for vectors:

> (type-of #(+ 1 2)) (SIMPLE-VECTOR 3)

Re:A Year of Clojure by puredanger on Friday December 31, 2010 @05:43PM (#2056683)
Yeah, I get it.