On Oct 16, 5:13 pm, Timothy Pratley <[EMAIL PROTECTED]> wrote:
> Maybe something along these lines?
>
> (defn myreplace [str [a b]]
>   (.replace str a b))
> (myreplace target search-replace)
> -> "heo world"

Same problem - it doesn't work within a doto block. This is where
JRuby-style reopening of the class and adding another method would be
handy. Here's an example from an app I'm currently writing, which
illustrates what I want to do:

(defn inner-square [i j]
  (+ i 1) (+ j 1) (- scale 1) (- scale 1))

(defmacro in-square [[i j] bg x y & body]
  `(let [[~i ~j] (topleft ~x ~y)]
    (doto ~bg
      [EMAIL PROTECTED])))

(defn fill-square [bg x y color]
  (in-square [i j] bg x y
             (setColor color)
             (fillRect (+ i 1) (+ j 1) (- scale 1) (- scale 1))))

Note that in fill-square I can either use in-square or inner-square,
but not both - in-square wraps everything in a doto block, and
fillRect expects an inline list of parameters.

martin



> I can see how it would be nice to 'splice in' from a variable like the
> [EMAIL PROTECTED] splicing from within a macro
--~--~---------~--~----~------------~-------~--~----~
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