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

Marco Baringer mb at bese.it
Sun Feb 10 12:19:29 UTC 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
similar:

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

so your example above is just:

(nesting
  (let ((x 12)))
  (flet ((foo (n) 
           (+ n 12))))
  (symbol-macrolet ((y (1+ x))))
  (progn
    (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:

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

-- 
-Marco
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