Hi All, I'm looking for general advice on using dynamic bindings to store flags/options that users pass to my code.
a) Should I use dynamic bindings for this purpose? (elaboration on "this purpose" below...) b) If I do, how might the new macros I've been hearing about (with-bindings, bound-fn) allow me to return lazy-seqs? My understanding of laziness and dynamic binding is still hazy, so the simper the explanations the more likely I'll be able to make sense of them. More on what I want to do. I imagine it's common: My project's API consists of a number of core functions that users call. Each of these functions accepts (optional) flags and options and then initiates calls to a host of back-end functions that do the heavy lifting and call one another extensively. I have two options for how to handle the flags/options: 1) My userland functions put them in a hash-map and pass them to my back-end code, where they are be passed around with every function call. This involves giving every one of my dozens/hundreds of functions an extra "options" argument. On the plus side they remain pure functions. On the minus side it's all somewhat cluttered. 2) My userland functions create an options hash-map and bind it to *options*. My back-end code references this var. If I go with (2), I mustn't return lazy-seqs, because when they are realized they will not have access to the flags and options the user specified. I would like, however, to be able to return lazy-seqs. What do people think? Would it be best to stay pure-functional for the purpose of handling flags/options? Would (2) be an abuse of dynamic binding? Or is dynamic binding appropriate? If it's appropriate, is there a way (with snapshot master Clojure or the new macros I've been reading about) to essentially close my lazy-seqs over the dynamic bindings? I've tried understanding the postings and assembla ticket about bound-fn, etc., but they're over my head. If bound-fn is suitable for this purpose, is it ready for prime time? Note that my back-end functions are not constructing their own lazy-seqs. They build lazy-seqs by mapping others of my functions over data, and the behavior of the mapped functions is affected by the flags/options. Garth --~--~---------~--~----~------------~-------~--~----~ 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---