Hi,

recently I ran in the a limitation of doto, that it only invokes
methods. However piping the object with -> does not work
also, since it's semantics are more like .. .

I'd like to propose the following chimera of doto and ->.

(defmacro doto->
  [obj & forms]
  (let [objx (gensym "obj__")]
    `(let [~objx ~obj]
       (do
         ~@(map (fn [f]
                  (if (seq? f)
                    `(~(first f) ~objx ~@(rest f))
                    `(~f ~objx)))
                forms))
       ~objx)))

It allows the full support of doto via the dot notation of
methods. And it supports on the other hand other functions
not only methods. One example is the new miglayout
interface in clojure-contrib.

(doto-> (new JFrame "Hello, World!")
  (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
  (miglayout SomeChild :AConstraint MoreChildren ...))

Any thoughts?

Sincerely
Meikel
--~--~---------~--~----~------------~-------~--~----~
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