First off, I wanted to thank Rich for an excellent presentation at Boston last night. It made me want to believe, but did induce a twinge of "and just what did *I* do in the last three years?".
Anyway, Rich made a fairly accurate point that CL's condition system is largely an special-case of dynamic functions. HANDLER-BIND and HANDLER-CASE set up a protocol, keyed on condition type, between a function and those dynamically above it. In Clojure, a similar protocol can be set up by simply rebinding functions in a "condition API" on the way down the stack. One key feature is missing: CL's condition system, C++'s (and Java's?) exceptions, and some others can optimize the usual (no throw) case by keying metadata off of the stack frames. Instead of rebinding functions each time down the stack, these mechanisms allow the thrower to incur the cost by walking back up the stack. Albeit in a hard- coded manner. But conditions/exceptions are not the only time when a function might want to walk the current call stack. The other major example being the "backtrace". I've toyed with a few spots where this could be an interesting trick in backtracking parsers (e.g. controlled removal of finalized stack frames). And some uses of continuations might be approximated by communicating state *over* intervening stack frames (which don't understand the protocol). Clojure already allows attaching metadata to functions. Is there any (efficient) way to access this for the stack in the current thread? Related question: Is there any way to "return" side-channel data past intermediate frames which don't understand the protocol (i.e. no throwing an exception and prematurely terminating them)? I'm thinking something like the following (defn knows-protocol [x] (put-side :side-x x) (+ x 5)) (defn oblivious [x] (knows-protocol (+ 2 x))) (side-channel-bind [retval (:side-x x) (:side-y y)] (oblivious 1) ; now retval=8, x=3, y=nil ) Where frames which know the protocol can do "multiple return" into named slots while those which don't simply "return" things unchanged. Thanks, Daniel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---