News for hackers. Stuff that matters.
Re:From C# on Mono, to Clojure on the JVM by jules on Saturday June 13, 2009 @12:28PM (#656246)
You say that

    (doto obj
        (.glBegin ...)
        (.methods ...)
        (.glEnd))
> I decided I wanted to factor out the (.glBegin ...) and (.glEnd). Aha, this is a job for macros!

    (gl-begin-end body) ; this should macro expand to:

    (do
        (.glBegin ...)
        body
        (.glEnd))
But why did you change `doto` to `do`?

Here's how you can do this:

    (defmacro gl-begin-end [obj & body]
      `(doto ~obj
          (.glBegin)
          ~@body
          (.glEnd)))
Re:From C# on Mono, to Clojure on the JVM by yummyfajitas on Saturday June 13, 2009 @01:41PM (#656308)
As I said, I know the programming mistake I made here (and that it reflects lack of knowledge of clojure on my part). But the problem I had with the doto macro could easily translate to a problem you have with my kwyjibo macro.

In python, I know what this code does, regardless of what happens at higher levels of indentation (ignoring some rarely used class-level hacking):

    f(a,b,c)
    g.h(i)
In lisp, I can't necessarily assume that

    (f a b c)
    (.h g i)
will actually call f on a,b,c and then call the h method of g on i. The ability to modify syntax programmatically implies that syntax (i.e. the s-exp structure) may not mean what you think it means.

I'm speculating that this may make collaboration more difficult.