Re: Little question about doto?

2012-06-23 Thread Vinzent
Well, yes, you've written it right: (doto sphere (.SetColor red) (.SetPosition 5 5 0)) ... or what the question was about? суббота, 23 июня 2012 г., 19:21:18 UTC+6 пользователь Antonio Recio написал: > > I create a white sphere at the beginning of my code, and later, after some

Re: Little question about doto?

2012-06-23 Thread Jim - FooBar();
I am not sure what exactly you're asking since you are already using 'doto' in your example so you already know what it does...Personally I would do something like this: (defn make-sphere [&{:keys [color position] :or {color 'white

Little question about doto?

2012-06-23 Thread Antonio Recio
I create a white sphere at the beginning of my code, and later, after some lines of code, I change the color and the position of this sphere. (def sphere (doto (mesh.sphere.) (.SetColor white)) (...) (...) (...) (.. sphere SetColor red) (.. sphere SetPosition 5 5 0)) To change the color

Re: 'dotimes' will not work inside a 'doto'...

2012-06-15 Thread Jim - FooBar();
lojure_core/clojure.core/future It takes only a few minutes to do so. Andy Thanks Andy I did not know we could do that... I logged in and added a warning for using 'dotimes' inside a 'doto' along with an example of the problem and the 2 remedies that I'm aware of...if a

Re: 'dotimes' will not work inside a 'doto'...

2012-06-14 Thread Andy Fingerhut
;> >>> Jim >>> >>> On 14/06/12 15:52, David Nolen wrote: >>>> >>>> On Thu, Jun 14, 2012 at 10:39 AM, Jim - FooBar(); >>>> wrote: >>>> Evaluates x then calls all of the methods and functions with the >>>> value of x s

Re: 'dotimes' will not work inside a 'doto'...

2012-06-14 Thread Jim - FooBar();
d functions with the value of x supplied at the front of the given arguments that's in the docstring for doto. but dotimes is not a method or a function is it? :) David, I think that Jim's point is that dotimes is a macro, not a method or a function, and yet the dotimes form i

Re: 'dotimes' will not work inside a 'doto'...

2012-06-14 Thread Andy Fingerhut
he >> value of x supplied at the front of the given arguments >> >> that's in the docstring for doto. but dotimes is not a method or a function >> is it? :) David, I think that Jim's point is that dotimes is a macro, not a method or a function, and yet the

Re: 'dotimes' will not work inside a 'doto'...

2012-06-14 Thread Walter Tetzner
On Thursday, June 14, 2012 8:09:50 AM UTC-4, Jim foo.bar wrote: > > It has to be 'do' instead of 'doto'... > Well, if you want to be able to use doto, you could do something like (doto foo (.bar x) (.baz y) (#(dotimes [i 10] (.zab % g -- You received

Re: 'dotimes' will not work inside a 'doto'...

2012-06-14 Thread Jim - FooBar();
27;s in the docstring for doto. but dotimes is not a method or a function is it? :) David -- 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 Note that posts from new members are

Re: 'dotimes' will not work inside a 'doto'...

2012-06-14 Thread David Nolen
On Thu, Jun 14, 2012 at 10:39 AM, Jim - FooBar(); wrote: > Evaluates x then calls all of the methods and functions with the > value of x supplied at the front of the given arguments > that's in the docstring for doto. but dotimes is not a method or a function is it? :) David --

Re: 'dotimes' will not work inside a 'doto'...

2012-06-14 Thread Jim - FooBar();
user=> (doc dotimes) - clojure.core/dotimes ([bindings & body]) Macro bindings => name n Repeatedly executes body (presumably for side-effects) with name bound to integers from 0 through n-1. nil user=> (doc doto) ----- clojure.core/doto

Re: 'dotimes' will not work inside a 'doto'...

2012-06-14 Thread Aaron Cohen
On Thu, Jun 14, 2012 at 8:09 AM, Jim - FooBar(); wrote: > (doto foo >  (.bar x) >  (.baz y) >  (dotimes [i 10] (.zab g))) > > won't work because foo is substituted as the second argument of 'dotimes'! > It has to be 'do' instead of 'doto

Re: 'dotimes' will not work inside a 'doto'...

2012-06-14 Thread Tassilo Horn
"Jim - FooBar();" writes: > (doto foo > (.bar x) > (.baz y) > (dotimes [i 10] (.zab g))) > > won't work because foo is substituted as the second argument of > 'dotimes'! The docs clearly state that. > It has to be 'do' instead o

'dotimes' will not work inside a 'doto'...

2012-06-14 Thread Jim - FooBar();
(doto foo (.bar x) (.baz y) (dotimes [i 10] (.zab g))) won't work because foo is substituted as the second argument of 'dotimes'! It has to be 'do' instead of 'doto'... very subtle trap... Jim -- You received this message because you are subscribed t

Re: doto

2010-08-27 Thread Sean Corfield
On Fri, Aug 27, 2010 at 2:06 PM, Mike Meyer wrote: >  (doto (new java.util.HashMap) (.put "a" 1) (.put "b" 2)) > nil Based on the docs, I was confused by that because I expected a hash map (with keys a and b). When I ran it locally, I got: # which was what I exp

Re: doto

2010-08-27 Thread kyle smith
I think the root of the misunderstanding is this: doto is NOT -> or - >> doto is typically used for initializing mutable java objects. So, instead of (let [foo ...] (.bar foo) (.baz foo) foo) , you can use (doto ... .bar .baz) It looks like you're trying to return the val

Re: doto

2010-08-27 Thread Mike Meyer
On Fri, 27 Aug 2010 13:39:34 -0700 (PDT) cej38 wrote: > I don't understand doto. Apparently. The doc says: user> (doc doto) - clojure.core/doto ([x & forms]) Macro Evaluates x then calls all of the methods and functions with the value of x supplied

doto

2010-08-27 Thread cej38
I don't understand doto. Suppose I try the following: user=> (doto 1 println) 1 1 user=> Now suppose I try the following: user=> (doto 1 #(println (inc %))) 1 user=> But if I make the following definition: (defn some-function [x] (println (inc x))) user=> (doto 1 som

doto doc fix

2010-03-03 Thread MarkSwanson
- value of x supplied at the from of the given arguments. The forms + value of x supplied at the front of the given arguments. The forms -- 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

Re: Reading items in doto from a vector (using swing)

2009-07-23 Thread Volker
That solved it, thank you! Volker --~--~-~--~~~---~--~~ 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 Note that posts from new members are moderated - please

Re: Reading items in doto from a vector (using swing)

2009-07-23 Thread Meikel Brandmeyer
Hi, the macro only works with the vector itself, because otherwise it only sees the symbol, but not the vector. What you want is a doseq loop. (defn add-elements [model elements] (doseq [elem elements] (.addElement model elem))) Then you can do: (doto (DefaultListModel.) (add

Reading items in doto from a vector (using swing)

2009-07-22 Thread Volker
I have some problems with using swing from clojure. Starting from the working choice list: (defn direct-ui "" [] (let [ tmp-my-list (doto (new DefaultListModel) (.addElement "Item1")

Re: Shouldn't "doto" be named just "with"

2009-03-07 Thread Dimiter "malkia" Stanev
> > > I think good arguments have been made for "doto," but I must say I > > prefer "with" slightly more. > > with can mean different things in different languages. In javascript, > it means the same thing as doto in clojure but in Python (and many > oth

Re: Shouldn't "doto" be named just "with"

2009-03-07 Thread Dan
On Fri, Mar 6, 2009 at 7:51 PM, rzeze...@gmail.com wrote: > > I think good arguments have been made for "doto," but I must say I > prefer "with" slightly more. with can mean different things in different languages. In javascript, it means the same thing as doto

Re: Shouldn't "doto" be named just "with"

2009-03-06 Thread rzeze...@gmail.com
I think good arguments have been made for "doto," but I must say I prefer "with" slightly more. FWIW, Groovy calls it "with." http://javajeff.blogspot.com/2008/11/getting-groovy-with-with.html The great thing about Clojure is that if this really bothered me I cou

Re: Shouldn't "doto" be named just "with"

2009-03-06 Thread Dimiter "malkia" Stanev
Thanks for the explanation guys! Having learned other languages, sometimes makes you wanna have the MEMORY UNDO FEATURE! On Mar 6, 3:37 pm, Meikel Brandmeyer wrote: > Hi, > > Am 07.03.2009 um 00:23 schrieb Laurent PETIT: > > > I'm not sure about this, but I think

Re: Shouldn't "doto" be named just "with"

2009-03-06 Thread Meikel Brandmeyer
Hi, Am 07.03.2009 um 00:23 schrieb Laurent PETIT: I'm not sure about this, but I think doto is named after the convention that a lot of side effecting functions/macros/special forms follow : share the "do" prefix if the name implies that there will be side effects. And

Re: Shouldn't "doto" be named just "with"

2009-03-06 Thread Laurent PETIT
Hello, I'm not sure about this, but I think doto is named after the convention that a lot of side effecting functions/macros/special forms follow : share the "do" prefix if the name implies that there will be side effects. And indeed, if you use doto with more than one following e

Shouldn't "doto" be named just "with"

2009-03-06 Thread Dimiter "malkia" Stanev
I've just started using doto, after seeing the celsius example on the Clojure page, but It brought back memories from Pascal days - http://csci.csusb.edu/dick/samples/pascal.syntax.html#with_statement It's probably nothing, but to me (with x (.Function1) (.Function2)) seems more rea

Re: possible bug with doto and function literals

2009-02-03 Thread Stephen C. Gilardi
On Feb 3, 2009, at 10:32 PM, kyle smith wrote: (map #(doto %1 (.add 2)) (doto (new java.util.ArrayList) (.add 1))) user=> (map #(doto %1 (.add 2)) (doto (new java.util.ArrayList) (.add 1))) java.lang.IllegalArgumentException: No matching method found: add for class java.lang.Inte

possible bug with doto and function literals

2009-02-03 Thread kyle smith
(map #(doto %1 (.add 2)) (doto (new java.util.ArrayList) (.add 1))) This seems like it should work, but does not. Can anyone confirm? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To po

Re: change in doto behavior

2008-12-03 Thread Blaine
t into the repl. It may be boring, but when you have only seconds for the pitch... On Dec 2, 10:12 pm, Stuart Halloway <[EMAIL PROTECTED]> wrote: > Yes.dotois more general now. The . is needed to indicate Java   > interop calls becausedotocan do other things which are not Java   > i

Re: change in doto behavior

2008-12-02 Thread Stuart Halloway
Yes. doto is more general now. The . is needed to indicate Java interop calls because doto can do other things which are not Java interop calls: (doto "double" println println) double double -> "double" Stuart > Can someone tell me whether this change was inten

change in doto behavior

2008-12-02 Thread .Bill Smith
Can someone tell me whether this change was intentional? In the 20080916 release, I get this: user=> (doto (new java.util.HashMap) (.put "a" "b")) java.lang.IllegalArgumentException: No matching method found: .put java.lang.IllegalArgumentException: No matching method

Patch for clojure.contrib.javadoc: doto

2008-11-28 Thread Meikel Brandmeyer
Hi, please find attached a patch for clojure.contrib.javadoc, which adapts the doto to the new syntax. Sincerely Meikel javadoc-doto.patch Description: Binary data smime.p7s Description: S/MIME cryptographic signature

Re: Modified doto

2008-11-19 Thread Rich Hickey
On Oct 23, 9:53 am, Rich Hickey <[EMAIL PROTECTED]> wrote: > On Oct 21, 10:30 am, mb <[EMAIL PROTECTED]> wrote: > > > Hi, > > > On 21 Okt., 14:41, mb <[EMAIL PROTECTED]> wrote:> (defmacro doto-> > > > The name is actually also up to dis

Re: Modified doto

2008-10-27 Thread mac
On Oct 25, 10:27 am, "V.Quixote" <[EMAIL PROTECTED]> wrote: > I'd like some version of doto that works on bare Classes (defmacro sdoto "Version of doto for use with static methods" [x & methods] `(do ~@(map (fn [m] (list '. x m))

Re: Modified doto

2008-10-25 Thread V.Quixote
I'd like some version of doto that works on bare Classes --~--~-~--~~~---~--~~ 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

Re: Modified doto

2008-10-24 Thread CuppoJava
On non-backwards compatible language changes in general, isn't it trivial to write a source-code converter? Especially given the ease of Clojure's macro system, all you would need is a systematic find and replace on any code that uses the current doto right? That would save the manua

Re: Modified doto

2008-10-24 Thread Christian Vest Hansen
On Thu, Oct 23, 2008 at 4:53 PM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > > > On Oct 21, 10:30 am, mb <[EMAIL PROTECTED]> wrote: >> Hi, >> >> On 21 Okt., 14:41, mb <[EMAIL PROTECTED]> wrote:> (defmacro doto-> >> >> The name is

Re: Modified doto

2008-10-24 Thread mac
On 23 Okt, 16:53, Rich Hickey <[EMAIL PROTECTED]> wrote: > On Oct 21, 10:30 am, mb <[EMAIL PROTECTED]> wrote: > > > Hi, > > > On 21 Okt., 14:41, mb <[EMAIL PROTECTED]> wrote:> (defmacro doto-> > > > The name is actually also up to dis

Re: Modified doto

2008-10-23 Thread Stephen C. Gilardi
On Oct 23, 2008, at 10:53 AM, Rich Hickey wrote: > Any thoughts on this as part of the upcoming bit of breaking changes? I think it would be a very useful change. I'm in favor. --Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed t

Re: Modified doto

2008-10-23 Thread Chouser
On Thu, Oct 23, 2008 at 10:53 AM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > I'd rather enhance doto to do this and not add another variant. The > break would be that current (doto x (foo 42)) would have to become > (doto x (.foo 42)). > > Any thoughts on this a

Re: Modified doto

2008-10-23 Thread Rich Hickey
On Oct 21, 10:30 am, mb <[EMAIL PROTECTED]> wrote: > Hi, > > On 21 Okt., 14:41, mb <[EMAIL PROTECTED]> wrote:> (defmacro doto-> > > The name is actually also up to discussion. doto is already > in use and this change is incompatible to "legacy" code

Re: Modified doto

2008-10-21 Thread mb
Hello, On 21 Okt., 19:08, Chouser <[EMAIL PROTECTED]> wrote: > Here's my implementation: > > (defmacro >>_ [& exprs] > (list 'let (apply vector (mapcat (fn [expr] (list '_ expr)) exprs)) '_ )) Now this is a nice idea. > I used it a couple times after first writing it, but have since failed > t

Re: Modified doto

2008-10-21 Thread Martin DeMello
On Oct 21, 5:41 am, mb <[EMAIL PROTECTED]> wrote: > > 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. Thanks! That

Re: Modified doto

2008-10-21 Thread Timothy Pratley
> Any thoughts? Awesome! :) --~--~-~--~~~---~--~~ 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 PROTE

Re: Modified doto

2008-10-21 Thread Sean Spencer
I also thought it was in the language and I just didn't know the name. Good to see it added! And "do-with" sounds like a good name to me. On Tue, Oct 21, 2008 at 12:33 PM, CuppoJava <[EMAIL PROTECTED]>wrote: > > +1 for do-with for me as well. > > Thank you for considering adding this to Clojure

Re: Modified doto

2008-10-21 Thread Chouser
On Tue, Oct 21, 2008 at 11:31 AM, mb <[EMAIL PROTECTED]> wrote: > > (xxx-> "Hello" (apply str <> [", " "World!"])) gives "Hello, World!". > > The <> is used to mark the "hole" where the value is to be inserted. I wrote something like this too. I called mine >>_ and used _ as the insert mark. He

Re: Modified doto

2008-10-21 Thread CuppoJava
+1 for do-with for me as well. Thank you for considering adding this to Clojure. I actually wrote this macro myself, but I've always thought it was in the API already and I just didn't know what it was called. --~--~-~--~~~---~--~~ You received this message because

Re: Modified doto

2008-10-21 Thread Rastislav Kassak
1 Okt., 17:24, Chouser <[EMAIL PROTECTED]> wrote: > >> I don't see much wrong with "doto->", though "do-with" or "do->" might > >> be okay. I'd probably vote against "do-unto-others-as" > > I would vote for do

Re: Modified doto

2008-10-21 Thread CuppoJava
If I understand the macro correctly, it takes an argument, and then inserts it as the second element into all of the following lists right? How about the name "with"? (with obj (. doSomething) (. doSomethingElse) (print stdOut)) I think i'm stealing it from Ruby, but i'm not sure. It's bee

Re: Modified doto

2008-10-21 Thread J. McConnell
> On 21 Okt., 17:24, Chouser <[EMAIL PROTECTED]> wrote: >> I don't see much wrong with "doto->", though "do-with" or "do->" might >> be okay. I'd probably vote against "do-unto-others-as" > I would vote for do-wit

Re: Modified doto

2008-10-21 Thread mb
Hi, On 21 Okt., 17:24, Chouser <[EMAIL PROTECTED]> wrote: > I don't see much wrong with "doto->", though "do-with" or "do->" might > be okay.  I'd probably vote against "do-unto-others-as" I would vote for do-with. Sincer

Re: Modified doto

2008-10-21 Thread mb
(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") >                (miglayo

Re: Modified doto

2008-10-21 Thread Chouser
d out, this is only useful when the methods (or functions) have side-effects -- their return values are thrown away. This explains the use of "do" in the original name, and is a good reason to keep "do" in the new name. I don't see much wrong with "doto->", th

Re: Modified doto

2008-10-21 Thread J. McConnell
I like "with", that's what JavaScript uses IIRC. - J. On Tue, Oct 21, 2008 at 11:10 AM, CuppoJava <[EMAIL PROTECTED]> wrote: > > If I understand the macro correctly, it takes an argument, and then > inserts it as the second element into all of the following lists > right? > How about the name "w

Re: Modified doto

2008-10-21 Thread Stephen C. Gilardi
On Oct 21, 2008, at 8:41 AM, mb wrote: > 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] >

Re: Modified doto

2008-10-21 Thread mb
Hi, On 21 Okt., 14:41, mb <[EMAIL PROTECTED]> wrote: > (defmacro doto-> The name is actually also up to discussion. doto is already in use and this change is incompatible to "legacy" code. I couldn't come up with a good alter

Re: Modified doto

2008-10-21 Thread Chouser
On Tue, Oct 21, 2008 at 8:41 AM, mb <[EMAIL PROTECTED]> wrote: > > (doto-> (new JFrame "Hello, World!") > (.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE) > (miglayout SomeChild :AConstraint MoreChildren ...)) > > Any thoughts? Beautiful. I've found

Modified doto

2008-10-21 Thread mb
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] (l