Re: version of -> short-circuiting on nil

2009-03-24 Thread Graham Fawcett
On Mon, Mar 23, 2009 at 6:49 PM, Laurent PETIT wrote: > Hello, > > there has been plenty of time to speak about that in the previous thread on > the subject, and it's a shame these interesting proposals had to wait for > the release of the functionality to pop up :-). > > But I think it's my faul

Re: version of -> short-circuiting on nil

2009-03-23 Thread Laurent PETIT
Hello, there has been plenty of time to speak about that in the previous thread on the subject, and it's a shame these interesting proposals had to wait for the release of the functionality to pop up :-). But I think it's my fault: when nobody did additional comments on the thread, I considered o

Re: version of -> short-circuiting on nil

2009-03-22 Thread Graham Fawcett
On Sun, Mar 22, 2009 at 9:05 PM, Stephen C. Gilardi wrote: > > On Mar 22, 2009, at 4:43 PM, Meikel Brandmeyer wrote: > >> Is .?. necessary? -> does the same job as .. by >> virtue of the .method notation, but is more general. >> So, why not get rid of .. and .?. completely? > > That sounds right

Re: version of -> short-circuiting on nil

2009-03-22 Thread Stephen C. Gilardi
On Mar 22, 2009, at 4:43 PM, Meikel Brandmeyer wrote: Is .?. necessary? -> does the same job as .. by virtue of the .method notation, but is more general. So, why not get rid of .. and .?. completely? That sounds right to me, Meikel. I'm in favor of keeping only -?> . --Steve smime.p7s De

Re: version of -> short-circuiting on nil

2009-03-22 Thread Meikel Brandmeyer
Hi, Am 22.03.2009 um 20:45 schrieb Stephen C. Gilardi: clojure.contrib.core/.?. is a symbol. Thanks for pointing out that it is one that's reserved to Clojure. Rich, should we rename clojure.contrib.core/.?. to avoid using a name reserved to Clojure? I'd like to throw in another thought:

Re: version of -> short-circuiting on nil

2009-03-22 Thread Stephen C. Gilardi
On Mar 22, 2009, at 2:28 PM, Michael Wood wrote: As was pointed out to me recently, http://clojure.org/reader says: "Symbols beginning or ending with '.' are reserved by Clojure." So, is .?. not a symbol (because it's called at compile time and at runtime there is no such thing as .?.)? i.e.

Re: version of -> short-circuiting on nil

2009-03-22 Thread Michael Wood
On Sun, Mar 22, 2009 at 11:42 AM, Laurent PETIT wrote: > OK, Stephen checked this in, thank you very much ! > > Two new symbols: As was pointed out to me recently, http://clojure.org/reader says: "Symbols beginning or ending with '.' are reserved by Clojure." So, is .?. not a symbol (because i

Re: version of -> short-circuiting on nil

2009-03-22 Thread Laurent PETIT
OK, Stephen checked this in, thank you very much ! Two new symbols: clojure.contrib.core/.?. clojure.contrib.core/-?> Regards, -- Laurent 2009/3/14 Laurent PETIT > Issue 34 ( http://code.google.com/p/clojure-contrib/issues/detail?id=34 ) > created with patch (both -?> and .?. defined in c

Re: version of -> short-circuiting on nil

2009-03-13 Thread Laurent PETIT
Issue 34 ( http://code.google.com/p/clojure-contrib/issues/detail?id=34 ) created with patch (both -?> and .?. defined in clojure.contrib.core, with unit tests in clojure.contrib.core.tests -- Laurent 3/13 Laurent PETIT > OK, so I think the consensus is on the names .?. and -?> . No problem

Re: version of -> short-circuiting on nil

2009-03-13 Thread Laurent PETIT
OK, so I think the consensus is on the names .?. and -?> . No problem with me. I'm willing to write the patch, but which patch ? I mean, do these macros deserve their own file (maybe not) ? Maybe adding them to the existing clojure.contrib.macros ? Or else, I was thinking about creating a new file

Re: version of -> short-circuiting on nil

2009-03-12 Thread Stephen C. Gilardi
On Mar 12, 2009, at 9:45 PM, Mark Volkmann wrote: On Thu, Mar 12, 2009 at 5:04 PM, Stephen C. Gilardi wrote: I like these: .?. -?> Given a choice between the two, I'd choose -?> The proposal was for naming "nil-safe" versions of the existing .. and -> functions. (->

Re: version of -> short-circuiting on nil

2009-03-12 Thread Mark Volkmann
On Thu, Mar 12, 2009 at 5:04 PM, Stephen C. Gilardi wrote: > > On Mar 12, 2009, at 5:45 PM, Laurent PETIT wrote: > >> * Concerning the name to give to this function : maybe ->? instead of ?->, >> if you think we can live with this "violation" to the predicate convention ? > > I like these: > >  

Re: version of -> short-circuiting on nil

2009-03-12 Thread Stephen C. Gilardi
On Mar 12, 2009, at 5:45 PM, Laurent PETIT wrote: * Concerning the name to give to this function : maybe ->? instead of ?->, if you think we can live with this "violation" to the predicate convention ? I like these: .?. -?> They fit with the criteria that Rich laid down i

Re: version of -> short-circuiting on nil

2009-03-12 Thread Laurent PETIT
Oh, I should have search through the ml first ... I see that we came to almost exactly the same code ;-) So it seems that finally, there are more than persons named "Stuart" that would like to see this function somewhere in clojure or clojure-contrib. I have the following questions : * Concern

Re: version of -> short-circuiting on nil

2009-03-12 Thread Stuart Sierra
On Mar 9, 8:12 pm, Laurent PETIT wrote: > When interacting with java code, and maybe in other pure clojure situations > as well (but I have not encountered the case myself), I was faced with > writing boiler plate code to check whether the return values of a chain of > calls to successive instanc

Re: version of -> short-circuiting on nil

2009-03-11 Thread rzeze...@gmail.com
Not that I have any immediate use for this at the moment, but I +1 your proposal. I make use of the ?. operating in Groovy, and it can be helpful. On Mar 10, 4:08 am, Laurent PETIT wrote: > Hello, > > 2009/3/10 Jason Wolfe > > > > > > > > > > (let [person (get-the-person)] > > >   (when-not (n

Re: version of -> short-circuiting on nil

2009-03-10 Thread Laurent PETIT
Hello, 2009/3/10 Jason Wolfe > > > (let [person (get-the-person)] > > (when-not (nil? person) > > (let [address (.getAddress person)] > > (when-not (nil? address) > > (let [street (.getStreet address)] > > (when-not (nil? street) > >(do-something-

Re: version of -> short-circuiting on nil

2009-03-09 Thread Jason Wolfe
> (let [person (get-the-person)] >   (when-not (nil? person) >     (let [address (.getAddress person)] >       (when-not (nil? address) >          (let [street (.getStreet address)] >             (when-not (nil? street) >                (do-something-finally-with-street street) > ?-> sounds

version of -> short-circuiting on nil

2009-03-09 Thread Laurent PETIT
Hello, When interacting with java code, and maybe in other pure clojure situations as well (but I have not encountered the case myself), I was faced with writing boiler plate code to check whether the return values of a chain of calls to successive instance members were null before continuing ...