That's actually quite a nifty use of the fact that code/data is the same in Clojure. But how do I test things out? In other words, how do I make sure that the expression defining a# is correct? Especially when any test has to itself be in the context of all the variables?
But more to the point I think there is a difference between possible and desirable. You're giving me what I asked for, e.g. a way to achieve my goal of not having the derived values be thunks. But I can't help but think that I'm just approaching the whole problem in the wrong way in Clojure. That's why I posted http://www.goland.org/sellorrent.pdf. I don't expect anyone to actually read, rather I was hoping some folks who know Clojure might just glance at it to get the rhythm of the math. It's the pattern, not the detail that matters. How should what is essentially a monster algebra equation be codified in Clojure? On Feb 17, 10:48 am, Tom Faulhaber <tomfaulha...@gmail.com> wrote: > You can combine let and binding like this to make this slightly more > elegant: > > (let [a# 'expr involving *A* *B* and *C*'' > b# 'expr involving *A* *B* and *C*'' > c# 'expr involving *A* *B* and *C*''] > (binding [*A* a# > *B* b# > *C* c#] > ...)) > > Note the x# form which does an implicit gensym for you so you get > unique names. > > This at least reduces it from n levels to two levels. It would be > pretty easy to build a parallel-binding macro that did this for you. > > hth, > > Tom > > On Feb 17, 10:09 am,Yaron<ygol...@gmail.com> wrote: > > > I did but it requires two levels of macro and that made me nervous. > > The problem is derived values. When defining a binding, near as I can > > tell, the values in the binding cannot see other values in the > > binding. In other words: > > > (def *A* 10) > > (binding [*A* 3 B (+ foo 1)] B) > > > Returns 11, not 4. > > > So to use the macro I have to: > > > (def *A* bogus_value) > > (def B bogus_value) > > > (defmacro in-environment [env & body] > > `(binding [*A* :A ..] > > (binding [B (+ *A* 1)...] > > �...@body)) > > > I think this would actually work. But it requires a bunch of > > accounting (all the bogus global defs) and introduces some worrisome > > ordering issues. For example, let's say I have a value C whose > > definition is (def C (+ B 1)). I can't define it using the previous > > macro. Because, again, bindings can't see each other. So now I'd have > > to write a macro that dynamically created a whole set of nested > > bindings. Which seems like a lot of work. > > > In other words: > > > (binding [*A* :A...] > > (binding [B (+ *A* 1)...] > > (binding [C (+ *B* 1)...] > > etc. > > > And I can't use let (which does allow for internal visibility) because > > then other functions I call will bind to the global value not the let > > value. > > > Yaron -- 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