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
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
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
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
;>
>>> 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
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
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
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
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
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
--
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
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
"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
(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
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
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
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
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
- 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
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
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
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")
>
> > 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
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
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
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
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
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
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
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
(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
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
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
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
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
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
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))
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
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
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
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
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
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
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
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
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
> 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
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
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
+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
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
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
> 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
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
(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
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
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
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]
>
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
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
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
61 matches
Mail list logo