I would like to have this in Clojure. Anybody else like it?
(defmacro ?.
"like .. but drops out on null object"
([x form]
`(. ~x ~form))
([x form & more]
`(if-let x# (. ~x ~form) (.? x# ~@more))))
BTW, my use case was (?. someClass getProtectionDomain getCodeSource
getLocation). This needs to drop out for null whenever someClass comes
from a ClassLoader that cannot report its location.
Stuart
P.S. A cooler name than "save navigation operator" would be welcome,
and I am not wedded to the Groovy syntax. I initially misremembered it
as ".?" which I think I may like better.
Does anybody not named Stuart also want to see this added to
Clojure? ;-)
Stuart
OK with me. Needs a dorky name to match. :-)