Re: the semantic of if-let macro

2013-01-31 Thread Stuart Halloway
The docs are clear that the test occurs before the bindings: (doc if-let) - clojure.core/if-let ([bindings then] [bindings then else & oldform]) Macro bindings => binding-form test If test is true, evaluates then with binding-form bound to the value of test, if not,

Re: the semantic of if-let macro

2013-01-30 Thread Mimmo Cosenza
On Thursday, January 31, 2013 1:49:40 AM UTC+1, Sean Corfield wrote: > but now that you've posted this, I > can see some potential for confusion when folks first encounter > if-let... Presumably the same confusion could arise for when-let? > yes, this is the confusion that you can incur in.

Re: the semantic of if-let macro

2013-01-30 Thread Mimmo Cosenza
On Wednesday, January 30, 2013 8:51:47 PM UTC+1, Gary Verhaegen wrote: > For your particular use-case, what you want is more along the lines of > > (if-let [errors (:password (fn-returning-errors))] > ...) > yes, precisely! mimmo -- -- You received this message because you are subscribed

Re: the semantic of if-let macro

2013-01-30 Thread Sean Corfield
>> >> >> >> (if-let [{errors :password} (function-returning-errors email password)] >> >> true >> >> false) >> >> >> >> In either case you never get the false branch when >> >> function-returning-errors retu

Re: the semantic of if-let macro

2013-01-30 Thread Mimmo Cosenza
>> wrote: > >> > >>> From the expansion we can see that if-let determine the result based on > >>> the second param, in your case: {:key2 "a string"}, not the local > >>> binding > >>> you assumed(key1), and > >>> I think it

Re: the semantic of if-let macro

2013-01-30 Thread Gary Verhaegen
e one you're > >> looking for > >> > >> Mimmo > >> > >> > >> On Jan 30, 2013, at 10:05 AM, James Xu > >> wrote: > >> > >>> From the expansion we can see that if-let determine the result based on > >>>

Re: the semantic of if-let macro

2013-01-30 Thread Ben Smith-Mannschott
t;> > >>> From the expansion we can see that if-let determine the result based on > >>> the second param, in your case: {:key2 "a string"}, not the local > >>> binding > >>> you assumed(key1), and > >>> I think it is reason

Re: the semantic of if-let macro

2013-01-30 Thread Mimmo Cosenza
inding >>> you assumed(key1), and >>> I think it is reasonable, for example, if we have the following code: >>> >>> (if-let [{key1 key2} {:key2 "a string"}] >>> true >>> false)) >>> >>> >>> Should if-le

Re: the semantic of if-let macro

2013-01-30 Thread James Xu
gt;> >> Should if-let determine the result based on key1? key2? IMO {key1 key2} >>in >> a whole is more reaonable. And {key1 key2} == {:key2 "a string"}, then >>the >> result is true. >> >> >> >> On 13-1-30 下午4:51, "Mimmo Cosenza&

Re: the semantic of if-let macro

2013-01-30 Thread Mimmo Cosenza
sumed(key1), and >> I think it is reasonable, for example, if we have the following code: >> >> (if-let [{key1 key2} {:key2 "a string"}] >> true >> false)) >> >> >> Should if-let determine the result based on key1? key2? IMO {key1 key

Re: the semantic of if-let macro

2013-01-30 Thread Mimmo Cosenza
ey1 key2} == {:key2 "a string"}, then the > result is true. > > > > On 13-1-30 下午4:51, "Mimmo Cosenza" wrote: > >> Hi all, >> I'm a little bit confused about the semantic of if-let macro. >> >> Suppose to call it as follows with

Re: the semantic of if-let macro

2013-01-30 Thread James Xu
uot;}] true false)) Should if-let determine the result based on key1? key2? IMO {key1 key2} in a whole is more reaonable. And {key1 key2} == {:key2 "a string"}, then the result is true. On 13-1-30 下午4:51, "Mimmo Cosenza" wrote: >Hi all, >I'm a little bit c

the semantic of if-let macro

2013-01-30 Thread Mimmo Cosenza
Hi all, I'm a little bit confused about the semantic of if-let macro. Suppose to call it as follows with map destructoring: (if-let [{key1 :key1} {:key2 "a string"}] true false)) It returns true. But, (let [{key1 :key1} {:key2 "a string"}] (if key1