Re: a denilling macro

2009-07-29 Thread nchubrich
Gentlemen--- Thanks for fixing my newbish error and showing me a better way to do it! Nick. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegrou

Re: a denilling macro

2009-07-28 Thread David Miller
> Unless you want the default value for a non initialized boolean value to be > true ... > > (let [x (or false true)] => whooops > In defense: ad hoc solutions don't need 100% coverage, mea culpa: I shouldn't have switched to it in discussing the macro. mea maxima culpa: I hesitated mentioning

Re: a denilling macro

2009-07-28 Thread John Harrop
On Mon, Jul 27, 2009 at 8:33 PM, nchubrich wrote: > Anyway I'd appreciate any critiques of the implementation; whether > it's a useful thing or not; if there are more idiomatic ways of doing > the same thing; and, if yes-no to the aforetwo, where's the best place > to add this functionality? W

Re: a denilling macro

2009-07-27 Thread Meikel Brandmeyer
Hi, as David has said, your macro works only for literal values, which doesn't make much sense.. I would implement i-let as follows: (defmacro let-default [bindings & body] `(let ~(vec (mapcat (fn [[sym value default]] `(value# ~value ~sym

Re: a denilling macro

2009-07-27 Thread Laurent PETIT
2009/7/28 David Miller > > (let [ x (or nil 4) >y (or 2 6) >z (or nil 10)] > (+ x y z)) > > => 16 > > This use of 'or' is fairly idiomatic, and not just in Lispish. Less > typing than 'if'. And you can use it or not, unlike i-let, which > forces you to put in a default for all

Re: a denilling macro

2009-07-27 Thread David Miller
(let [ x (or nil 4) y (or 2 6) z (or nil 10)] (+ x y z)) => 16 This use of 'or' is fairly idiomatic, and not just in Lispish. Less typing than 'if'. And you can use it or not, unlike i-let, which forces you to put in a default for all bindings. Regarding the implementation of

a denilling macro

2009-07-27 Thread nchubrich
I've been learning Clojure. I just wrote a macro to be used like so: (i-let [x nil 4 y 2 6 z nil 10] (+ x y z)) => 16 I.E. if the first value in the triple is nil, bind it to the second value in the triple. This is useful when you want to let something that might be nil and