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

Ron Garret ron at awun.net
Sat Feb 9 17:34:41 PST 2008


In the context of a debate over Paul Graham's new Arc language I wrote  
a macro called binding-block or BB for short.  The intent of the macro  
was to illustrate how the relentless pursuit of brevity would lead to  
some really perverse looking code.  But now, ironically, I've actually  
found binding-block kind of growing on me.  It's basically a keyword- 
based replacement for a bunch of binding constructs (LET, MULTIPLE- 
VALUE-BIND, DESTRUCTURING-BIND, and most WITH-XXX forms) kinda-sorta  
like LOOP is a keyword-based replacement for DO, DOTIMES, MAP, etc.   
The syntax is:

(bb
  [var form |
   :mv (var1 var2 ...) form |
   :db pattern form |
   :with spec |
   form]*
   [result]
)

So, for example, this code:

(let ((x (foo)))
  (do-something)
  (multiple-value-bind (x y z) (baz)
    (do-something-else)
    (destructuring-bind (q (r) s) (frotz)
      (do-yet-another-thing)
      (with-open-file (f "blotz")
        (frobnosticate)
        result))))

Would look like this using BB:

(bb
  x (foo)
  (do-something)
  :mv (x y z) (baz)
  (do-something-else)
  :db (q (r) s) (frotz)
  (do-yet-another-thing)
  :with open-file (f "blotz")
  (frobnosticate)
  result)

I'd like to know how people feel about this.  Does it make you recoil  
in horror?  Do you think it's kinda cool?  Personally, though it feels  
very unlispy, I find that I kind of like the way it prevents my code  
from creeping off the right side of the screen.

(I conjecture that there will be a very strong correlation between  
people who like LOOP and people who like BB.)

The reason I ask is that I'm getting some code ready to release, and  
I'm wondering if I should use BB in it or not.

rg




More information about the Openmcl-devel mailing list