On Oct 6, 9:36 am, Stuart Halloway <[EMAIL PROTECTED]> wrote:
> Yes, that's better. Glad you like the idea.
>
> Does anybody not named Stuart also want to see this added to
> Clojure? ;-)
>
> Stuart
>
> > On Oct 3, 3:13 pm, Stuart Halloway <[EMAIL PROTECTED]> wrote:
> >> (defmacro ?.
> >>    "like .. but drops out on null object"
> >>    ([x form]
> >>       `(. ~x ~form))
> >>    ([x form & more]
> >>       `(if-let x# (. ~x ~form) (.? x# [EMAIL PROTECTED]))))
>
> > Interesting -- I like it.  It doesn't seem to be totally compatible
> > with "..", though:
>
> > user=> (?. System (getenv "SHELL") (startsWith "/bin") getClass
> > getName)
> > java.lang.Exception: Unable to resolve symbol: startsWith in this
> > context (NO_SOURCE_FILE:62)
>
> > Also, if-let could give the wrong result in the (admittedly unlikely)
> > situation that one of the methods returns Boolean.FALSE.
> > Here's another take:
>
> > (defmacro ?..
> >   "like .. but stops and returns nil if any method returns nil"
> >   ([x form]
> >      `(.. ~x ~form))
> >   ([x form & more]
> >      `(let [x# (?. ~x ~form)]
> >         (if (nil? x#) nil
> >             (?. x# [EMAIL PROTECTED])))))
>
> > user=> (?.. System (getenv "SHELL") (startsWith "/bin") getClass
> > getName)
> > "java.lang.Boolean"
> > user=> (?.. System (getenv "FOO") (startsWith "/bin") getClass
> > getName)
> > nil
>

I'm not opposed, but we'll need to find another name. Leading ? is a
likely candidate for rule syntax, and trailing means predicate.

.?.

?

Rich

--~--~---------~--~----~------------~-------~--~----~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to