Meeting recap, Pipes/Tubes/Clinks, and next meeting info

At our latest meeting, we discussed macros and adopted a capstone project, an open-source Clojure implementation of some of the functions of Yahoo Pipes.


Regarding macros, we touched on the chain of events when a Clojure program is evaluated: evaluation runs from top to bottom, and each S-expression is macro-expanded (if possible) and then evaluated. If an expression expands into something that itself contains a macro, the the new macro expression will be expanded before it is evaluated. This allows a macro to use a previously defined function in the determination of its expansion.

“Macros” in Lisp are very different from “macros” in other languages, as they allow the programmer to use all the power of Lisp to determine the macro’s expansion. Macros are not first-class members of the Clojure language, however. You cannot use them as you use functions–you can not use them with map or apply, for example–because macroexpansion happens before an expression can be used in this way.

Seeing stars

We also talked about “star” functions and macros. The macroexpansion of an expression that uses ‘and‘ includes something called let*:

(macroexpand '(and 1 2 3))
->(let* [and__2863 1]
(if and__2863 (clojure.core/and 2 3) and__2863))

We concluded that you really aren’t supposed to see let*. You only do in this case because macroexpand completely expands the expression it is given, and it turns out that let is a macro whose definition includes the mysterious let*. In fact, a lot of Clojure’s core macros use “star” constructs that appear to be special forms. Some digging at the REPL confirmed that they are not symbols. Likely the “star” forms are transformed by the Clojure parser directly into Java. If you have some special knowledge about this, please post a comment or join our discussion group. We’d like to know more.

Capstone project

Luke presented the case for a project that implemented some of the Yahoo Pipes application. By general acclamation we adopted this project as our capstone. We’ve decided to spend the next two weeks hacking on the basic problems of the project ourselves, keeping in touch through the group mailing list. David set up a github repo for us, with a wiki for collaboration. There you can find the summary of our initial work on defining the project, thanks to Keith. Serge dug up Yahoo’s Pipes documentation.

We’re calling this Tubes right now (as in “teh tubes”), but a final decision on the name (I’m not saying I don’t like Tubes) is one of many tasks we’re deferring. Right now we just want to get things moving. Personally, I expect Paul to have it all done by this afternoon.

Multimethods on Sunday, April 19th, 1pm

Our next meeting will be at least partly devoted to the final topic in Stu’s book: multimethods. Read chapter 8 of Programming Clojure and bring any questions or comments you’d like to discuss. Please notice two things about the next meeting date: 1) it is in two weeks, not three; and 2) it is on a Sunday. The location is still HacDC’s meeting space at St. Stephens, and the time is still 1pm. We hope to see you there.


2 Responses to Meeting recap, Pipes/Tubes/Clinks, and next meeting info

  1. Chouser says:

    As you noted, several forms that are documented as “special forms” are in fact currently macros. These generally expand to something that uses the “star-form” which is truly a special form. For example, ‘fn’ is a macro that expands to ‘fn*’. The ‘fn*’ form is then handled specially by the compiler.

    The reason the macro forms are documented as special forms is because the fact that they’re actually macros is a (possibly temporary) implementation detail. For example ‘if’ really was a special form until fairly recently. Currently it’s a macro and ‘if*’ is the special form. The only reason for this change was to support the -Dclojure.assert-if-lazy-seq=true flag. Similarly, each of the other special-forms that are implemented as macros are that way for specific reasons: let*, loop* and fn* don’t support destructuring, but let, loop and fn do. letfn provides a more convenient syntax than letfn*

    So it’s ok to see the star forms, but don’t let them scare you, and don’t try to use them directly.

  2. goodmike says:

    Thanks, Chris. We figured the non-star forms were the intended developer interface and that any starred stuff “below” them were to be considered volatile and off-limits, but we appreciate the clarification.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: