Here is the if-let*:
(defmacro if-let*
([bindings then]
`(if-let* ~bindings ~then nil))
([bindings then else]
(if (seq bindings)
`(if-let [~(first bindings) ~(second bindings)]
(if-let* ~(drop 2 bindings) ~then ~else)
~(if-not (second bindings) else))
then)))
And when-let*:
(defmacro when-let* (
On Fri, Jan 4, 2013 at 2:35 PM, Michał Marczyk wrote:
> Note that if-let -- as it currently stands, I mean -- doesn't make the
> binding available to the "else" branch (so there's no way of telling
> if the init expression turned out to be false or nil). The above would
> be a natural extension of
On Fri, Jan 4, 2013 at 11:59 AM, Marko Topolnik wrote:
> I do this regurarly:
>
> (-> x (fun1 arg1) (#(fun2 arg2 %)) ...)
>
> It works, but I still don't like it, I find that extra hash and parens
> distasteful.
>
>
Thanks for that idea. Don't know why I never thought to do that.
--
You receive
On 4 January 2013 21:45, Anthony Grimes wrote:
> Really? I didn't read the thread, but I wouldn't expect that behavior at
> all. How would you know which bindings to use given the short circuiting?
> Unless it would bind the short circuited bindings to nil, which also seems
> weird. I would absolu
On Friday, January 4, 2013 1:35:45 PM UTC-6, puzzler wrote:
> On Fri, Jan 4, 2013 at 9:02 AM, Edward Tsech
> > wrote:
>
>> Thanks Dave! Seems like different people expect slightly different
>> behavior.
>
>
> Are we reading the same thread? When I looked at it, it seemed that there
> was actua
On Friday, January 4, 2013 8:35:45 PM UTC+1, puzzler wrote:
>
> On Fri, Jan 4, 2013 at 9:02 AM, Edward Tsech
> > wrote:
>
>> Thanks Dave! Seems like different people expect slightly different
>> behavior.
>
>
> +1, I agree with points both on threading macros and on redundant
indentation due t
udge the folks who love the threading
macros and are looking forward to the expansion of the "threading DSL" in
the new version. Different people have different stylistic preferences,
and that's fine. However, I'm disappointed that the if-let/when-let camp
hasn't seen more
On Fri, Jan 04, 2013 at 08:58:40AM +0100, Tassilo Horn wrote:
At least in my experience, it usually matters a lot which form actually
evaluated to nil. But it's easy to write a macro `if-let-all' or so,
which would expand into
(let [x 1 y nil z 3]
(if (and x y z)
(+ x y z)
0))
i
On Thu, Jan 03, 2013 at 11:14:30PM -0800, Evan Mezeske wrote:
Wouldn't it be more accurately named "if-and-let" if it supported that? E.g.
(if (and x y z) ...).
I can see regular if-let being useful with more than one form, just
using the last value for the conditional.
(if-let [a expr, b
Thanks Dave! Seems like different people expect slightly different behavior.
On Friday, January 4, 2013 9:34:38 PM UTC+6, daveray wrote:
>
> I don't know if it will answer your history question, but there was a
> fairly long discussion about this last year:
>
>
> https://groups.google.com/for
I don't know if it will answer your history question, but there was a
fairly long discussion about this last year:
https://groups.google.com/forum/?fromgroups=#!searchin/clojure/let-else/clojure/1g5dEvIvGYY/EWjwFGnS-rYJ
Cheers,
Dave
On Fri, Jan 4, 2013 at 7:23 AM, Edward Tsech wrote:
> Sorr
Sorry guys, I forget to mention that it should behave like "let" in Clojure
or like "let*" in Scheme.
I mean e.g.:
(if-let* [x 1 y nil z (inc y)]
(+ x y z)
0) ; => 0
;; (inc y) shouldn't be evaluated here.
Which means "and" doesn't work there.
In terms of implementation I mean smth like tha
I don't know the history of the answer to "why", except perhaps as hinted by
Evan's answer, which is that it becomes implicit how to combine the results of
the multiple values to get the final true/false for the if condition. You
imply "and", which is a perfectly reasonable choice.
My main rea
Edward Tsech writes:
> java.lang.IllegalArgumentExcepdtion: if-let requires exactly 2 forms
> in binding vector(NO_SOURCE_FILE:1)
>
> Why doesn't "if-let" support any even amount of binding forms as "let"
> does?
>
> e.g.
> (if-let [x 1 y 2 z 3]
> (+ x y z)
> 0) ; => 6
>
> (if-let [x 1 y nil
Wouldn't it be more accurately named "if-and-let" if it supported that?
E.g. (if (and x y z) ...).
On Thursday, January 3, 2013 10:24:57 PM UTC-8, Edward Tsech wrote:
>
> Hey guys,
>
> if-let and when-let macros support only 2 forms in binding vector:
>
> (if-let [x 1 y 2]
> ...)
> java.lang.I
Hey guys,
if-let and when-let macros support only 2 forms in binding vector:
(if-let [x 1 y 2]
...)
java.lang.IllegalArgumentExcepdtion: if-let requires exactly 2 forms in
binding vector(NO_SOURCE_FILE:1)
Why doesn't "if-let" support any even amount of binding forms as "let" does?
e.g.
(if-l
16 matches
Mail list logo