Re: docstrings of if-let and when-let incorrect

2012-05-21 Thread Aaron Cohen
On Mon, May 21, 2012 at 1:43 PM, Jay Fields wrote: > There's a few issues there, first of which is that the code doesn't > evaluate to what's shown: > REPL started; server listening on localhost port 21867 > user=> > (if-let [a 1] >(if-let [b 2] > (if-let [c nil] > [a b c] >

Re: docstrings of if-let and when-let incorrect

2012-05-21 Thread Jay Fields
There's a few issues there, first of which is that the code doesn't evaluate to what's shown: REPL started; server listening on localhost port 21867 user=> (if-let [a 1] (if-let [b 2] (if-let [c nil] [a b c] [a b c]) [a b c]) [a b c]) java.lang.Exception: Unabl

Re: docstrings of if-let and when-let incorrect

2012-05-21 Thread Borkdude
I guess it wouldn't hurt having them available in the else, even if people won't use them often. On Monday, May 21, 2012 7:11:05 PM UTC+2, Aaron Cohen wrote: > > On Wed, May 16, 2012 at 9:53 AM, Walter Tetzner < > robot.ninja.saus...@gmail.com> wrote: > >> On Wednesday, May 16, 2012 9:16:29 AM UT

Re: docstrings of if-let and when-let incorrect

2012-05-21 Thread Aaron Cohen
On Wed, May 16, 2012 at 9:53 AM, Walter Tetzner < robot.ninja.saus...@gmail.com> wrote: > On Wednesday, May 16, 2012 9:16:29 AM UTC-4, Aaron Cohen wrote: >> >> Saying something is obvious and then using the word monad a paragraph >> later is contradictory. ;) >> >> What should happen on the else b

Re: docstrings of if-let and when-let incorrect

2012-05-21 Thread Borkdude
Wow, the discussion continued! I agree on what most people have said: AND-combined and none of the bindings available in the else. On Friday, May 18, 2012 7:20:06 AM UTC+2, FrankS wrote: > > Christophe Grand was "experimenting" with some extensions to if-let and > when-let that had implicit AN

Re: docstrings of if-let and when-let incorrect

2012-05-17 Thread Frank Siebenlist
Christophe Grand was "experimenting" with some extensions to if-let and when-let that had implicit ANDs for the let-forms: https://github.com/cgrand/parsley/blob/master/src/net/cgrand/parsley/util.clj It feels intuitive to me to allow multiple if-let-forms like cgrand implements, and I can cert

Re: docstrings of if-let and when-let incorrect

2012-05-16 Thread dgrnbrg
I too assumed that if/when-let would support multiple bindings, short- circuiting if one failed, when I started learning Clojure. It seems that short-circuiting multiple bindings isn't surprising. On May 16, 10:56 am, Jay Fields wrote: > I've also attempted to use if/when-let with multiple bindin

Re: docstrings of if-let and when-let incorrect

2012-05-16 Thread Jay Fields
I've also attempted to use if/when-let with multiple bindings in the past. I assumed that it would behave as 'AND' and that no bindings would be available in 'else' Cheers, Jay On Wed, May 16, 2012 at 10:29 AM, Dan Cross wrote: > On Wed, May 16, 2012 at 9:16 AM, Aaron Cohen wrote: > > On Wed,

Re: docstrings of if-let and when-let incorrect

2012-05-16 Thread Dan Cross
On Wed, May 16, 2012 at 9:16 AM, Aaron Cohen wrote: > On Wed, May 16, 2012 at 9:10 AM, Walter Tetzner > wrote: >> To make the bindings work like let, where later bindings can see previous >> bindings, I think the most natural way to do it is to have the bindings >> behave like the maybe monad. >

Re: docstrings of if-let and when-let incorrect

2012-05-16 Thread Walter Tetzner
On Wednesday, May 16, 2012 9:16:29 AM UTC-4, Aaron Cohen wrote: > > Saying something is obvious and then using the word monad a paragraph > later is contradictory. ;) > > What should happen on the else branch of the if-let; which bindings are in > scope and what would be their values? > > None of

Re: docstrings of if-let and when-let incorrect

2012-05-16 Thread Chris Ford
Personally, I would intuitively assume that none of the bindings from if-let would be available in the else branch. On 16 May 2012 14:36, Moritz Ulrich wrote: > On Wed, May 16, 2012 at 3:16 PM, Aaron Cohen wrote: > > What should happen on the else branch of the if-let; which bindings are > in >

Re: docstrings of if-let and when-let incorrect

2012-05-16 Thread Michael Gardner
On May 16, 2012, at 8:16 AM, Aaron Cohen wrote: > Saying something is obvious and then using the word monad a paragraph later > is contradictory. ;) If the word "monad" is scary, just pretend he said "it should short-circuit" instead. ;) > What should happen on the else branch of the if-let; w

Re: docstrings of if-let and when-let incorrect

2012-05-16 Thread Moritz Ulrich
On Wed, May 16, 2012 at 3:16 PM, Aaron Cohen wrote: > What should happen on the else branch of the if-let; which bindings are in > scope and what would be their values? This is kind of tricky. My opinion tends to "all bindings", but then it's difficult to handle lazy evaluation like in (or (cheap

Re: docstrings of if-let and when-let incorrect

2012-05-16 Thread Aaron Cohen
On Wed, May 16, 2012 at 9:10 AM, Walter Tetzner < robot.ninja.saus...@gmail.com> wrote: > On Wednesday, May 16, 2012 9:01:49 AM UTC-4, Stuart Sierra wrote:How would >> multiple bindings for if-let or when-let work? Should every binding be >> testedd? Should they be and-ed together? Should it short

Re: docstrings of if-let and when-let incorrect

2012-05-16 Thread Walter Tetzner
> > On Wednesday, May 16, 2012 9:01:49 AM UTC-4, Stuart Sierra wrote:How would > multiple bindings for if-let or when-let work? Should every binding be > testedd? Should they be and-ed together? Should it short-circuit if the > first is false? > > I don't think there are obvious answers to thos

Re: docstrings of if-let and when-let incorrect

2012-05-16 Thread Stuart Sierra
How would multiple bindings for if-let or when-let work? Should every binding be testedd? Should they be and-ed together? Should it short-circuit if the first is false? I don't think there are obvious answers to those questions. -S -- You received this message because you are subscribed to the

Re: docstrings of if-let and when-let incorrect

2012-05-16 Thread Vinzent
> > As the logical AND of all of the multiple forms? The OR? Only use the > first expression? Only the last? > It should be AND. -- 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 t

Re: docstrings of if-let and when-let incorrect

2012-05-15 Thread Dan Cross
On Tue, May 15, 2012 at 3:47 PM, Walter Tetzner wrote: > On Tuesday, May 15, 2012 3:41:58 PM UTC-4, Dan Cross wrote: >> My own personal opinion is that it makes sense in combination with 'and', >> but others may feel differently.  E.g., >> >>     (when-let [a (allocate-thing) b (read-into-thing a)

Re: docstrings of if-let and when-let incorrect

2012-05-15 Thread Michael Gardner
On May 15, 2012, at 3:15 PM, Andy Fingerhut wrote: > If if-let/when-let had multiple bindings, how would you propose to define the > condition of whether to do the "then" branch? > > As the logical AND of all of the multiple forms? The OR? Only use the first > expression? Only the last? > >

Re: docstrings of if-let and when-let incorrect

2012-05-15 Thread Andy Fingerhut
If if-let/when-let had multiple bindings, how would you propose to define the condition of whether to do the "then" branch? As the logical AND of all of the multiple forms? The OR? Only use the first expression? Only the last? I don't see that any of those is any more clear or "least surpris

Re: docstrings of if-let and when-let incorrect

2012-05-15 Thread Walter Tetzner
On Tuesday, May 15, 2012 3:41:58 PM UTC-4, Dan Cross wrote: > > My own personal opinion is that it makes sense in combination with 'and', > but others may feel differently. E.g., > > (when-let [a (allocate-thing) b (read-into-thing a) c > (extract-something-from-thing b)] > (do-somethi

Re: docstrings of if-let and when-let incorrect

2012-05-15 Thread Dan Cross
On Tue, May 15, 2012 at 3:26 PM, Aaron Cohen wrote: > Does the principle of least surprise suggest that multiple bindings be > combined with AND or OR? My own personal opinion is that it makes sense in combination with 'and', but others may feel differently. E.g., (when-let [a (allocate-t

Re: docstrings of if-let and when-let incorrect

2012-05-15 Thread Walter Tetzner
On Tuesday, May 15, 2012 3:26:52 PM UTC-4, Aaron Cohen wrote: > > Does the principle of least surprise suggest that multiple bindings be > combined with AND or OR? > > For `when-let', I would expect it to work like nested when-lets: (when-let [x (exp-1) y (exp-2 x) z (exp-

Re: docstrings of if-let and when-let incorrect

2012-05-15 Thread Aaron Cohen
Does the principle of least surprise suggest that multiple bindings be combined with AND or OR? --Aaron On Tue, May 15, 2012 at 3:09 PM, Hubert Iwaniuk wrote: > I tried using if-let with multiple binding in past as well. > Following least surprise principle, I would like to see support for > mu

Re: docstrings of if-let and when-let incorrect

2012-05-15 Thread Evan Gamble
If if-let and when-let don't get support for multiple bindings, you could try https://github.com/egamble/let-else . On Tuesday, May 15, 2012 12:09:08 PM UTC-7, Hubert Iwaniuk wrote: > > I tried using if-let with multiple binding in past as well. > Following least surprise principle, I would like

Re: docstrings of if-let and when-let incorrect

2012-05-15 Thread Hubert Iwaniuk
I tried using if-let with multiple binding in past as well. Following least surprise principle, I would like to see support for multiple bindings. Cheers, Hubert. Vinzent May 15, 2012 5:47 PM Or maybe if-let and when-let should support multiple bindings, like the

Re: docstrings of if-let and when-let incorrect

2012-05-15 Thread Vinzent
Or maybe if-let and when-let should support multiple bindings, like the doc states. воскресенье, 13 мая 2012 г., 4:55:40 UTC+6 пользователь Borkdude написал: > > The docstring of if-let is as follows: > > bindings => binding-form test > > If test is true, evaluates then with binding-form bound to

Re: docstrings of if-let and when-let incorrect

2012-05-15 Thread Stuart Sierra
Reasonable enough. Patch welcome. -S -- 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

docstrings of if-let and when-let incorrect

2012-05-14 Thread Borkdude
The docstring of if-let is as follows: bindings => binding-form test If test is true, evaluates then with binding-form bound to the value of test, if not, yields else I think it should be mentioned in the docs that if-let and when-let support only *one binding*, not multiple bindings (like for