[Openmcl-devel] Poll: what do you think of binding-block?

Marco Baringer mb at bese.it
Sun Feb 10 04:19:29 PST 2008

"Lennart Staflin" <lstaflin at gmail.com> writes:

> I've experimented with something similar (but with more parentheses):
> (nest
>   (:var x 12)
>   (:fn foo (n) (+ n 12))
>   (:alias y (1+ x))
>   (list x (foo x) y))
> becomes
> (LET ((X 12))
>   (FLET ((FOO (N) (+ N 12)))
>     (SYMBOL-MACROLET ((Y (1+ X)))
>       (LIST X (FOO X) Y))))

i've also experimented with (but never ended up using) something

(defmacro nesting (&rest clauses)
  (if clauses
      `(,@(first clauses) (nesting ,@(rest clauses)))

so your example above is just:

  (let ((x 12)))
  (flet ((foo (n) 
           (+ n 12))))
  (symbol-macrolet ((y (1+ x))))
    (list x (foo x) y)))

I tend to prefer this above other, less verbose, macros since it doesn't
require you to learn any new names and adding new kinds of binding
clauses requires you to just write it:

  (with-open-file (input "/input" :direction :input))
  (with-open-file (output "/output" :direction :output))

Ring the bells that still can ring.
Forget your perfect offering.
There is a crack in everything.
That's how the light gets in.
	-Leonard Cohen

More information about the Openmcl-devel mailing list