3 ms·
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) #(p
by thurn 16y ago
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.
- zck 16y agoArguably, 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.
- ataggart 16y agoThe 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.
- zck 16y agoAh, 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)