Hello Stephen,

On 21 Okt., 17:05, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> Is the ".." aspect of it the "automatically make a list if it's not  
> one" part?
This is actually a -> aspect. What I meant was:
(.. x (getModel) (getRoot) (state))
is equivalent to
(-> x .getModel .getRoot .state)

That is the reason, why (-> frame (.method1 ...) (.method2 ...))
doesn't work in the given examples. The methods most likely
don't return frame...

> (doto-> (JFrame. "Hello Frame")
>                (miglayout (JLabel. "Hello Label"))
>                .pack
>                (.setVisible true))
This is exactly my first use case. :)

> It seems a key thing to remember here is that while this does return a  
> useful value, it's primarily a construct for side effects. We're  
> calling these Clojure functions because they're compositions of calls  
> that have side effects either on the state of obj or on the system as  
> a whole (e.g., showing a window). We're throwing away the values  
> produced by the individual calls. This is in contrast to "->" where  
> each call's result is consumed by the next function in the thread.
Yes. This is intended as an augmented (or improved or whatever) doto.
It's purely for side effects, but very handy for object creation,
which
needs to call several methods on the same object.

For functional uses -> is almost perfect. Hmm... When we currently
talk about it... How about this:

(defmacro xxx->
  ([x form] (if (seq? form)
              (let [[hd tl] (split-with #(not= '<> %) form)]
                (if tl
                  `(~@(concat hd (cons x (rest tl))))
                  `(~(first form) ~x ~@(rest form))))
              (list form x)))
  ([x form & more] `(-> (-> ~x ~form) [EMAIL PROTECTED])))

Disclaimer: this is only a rough idea!!! Let alone a correct
implementation.

The idea is to provide a way to let the piped argument be someting
else than the first one.

(xxx-> "Hello" (apply str <> [", " "World!"])) gives "Hello, World!".

The <> is used to mark the "hole" where the value is to be inserted.
Should this be only replaced in the top expression? Or also in
sub expressions? Without zipper in boot.clj? Is this a good idea
in the first place?

Acknowledgement: <> is stolen from the cut notation of some SRFI.

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