Thanks again!
On Apr 27, 6:41 pm, Richard Lyman wrote:
> There's a section on the wiki with almost the exact same title:
>
> http://en.wikibooks.org/wiki/Clojure_Programming/Examples#Invoking_Ja...
>
> If I'm understanding the question correctly that should do what you're
> wanting to do.
>
> -R
There's a section on the wiki with almost the exact same title:
http://en.wikibooks.org/wiki/Clojure_Programming/Examples#Invoking_Java_method_through_method_name_as_a_String
If I'm understanding the question correctly that should do what you're
wanting to do.
-Rich
On Sun, Apr 26, 2009 at 11:
On Apr 27, 3:49 am, fft1976 wrote:
> Can there be Vars without names? Can I have a vector of Vars?
Vars always have names, but you can create temporary Vars using with-
local-vars. If you want to create a vector of unnamed, mutable
objects, you probably want Refs or Atoms instead.
-Stuart Sier
fft1976 a écrit :
>
> On Apr 26, 9:21 am, Stuart Sierra wrote:
>
>> "resolve" will find the Var
>> that is named by the symbol.
>>
>
> Can there be Vars without names? Can I have a vector of Vars?
>
You can, see with-local-vars for example.
--~--~-~--~~~--
On Apr 26, 9:21 am, Stuart Sierra wrote:
> "resolve" will find the Var
> that is named by the symbol.
Can there be Vars without names? Can I have a vector of Vars?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Yes. The following should also work, without calling into Clojure
implementation methods:
(defn eval-string [s]
(eval (read-string s)))
-Stuart Sierra
On Apr 26, 1:50 pm, timc wrote:
> Thanks Stuart.
>
> I have figured out another way, which is much more general (and uses
> the lowest level o
Thanks Stuart.
I have figured out another way, which is much more general (and uses
the lowest level of how Clojure works).
(defn evalStr [s] (clojure.lang.Compiler/eval (clojure.lang.RT/
readString s)))
will (attempt to) execute any valid form (i.e. the string that is the
source of the form).
This will work:
((resolve (symbol "+")) 1 2 3)
To answer your question, a symbol is just a symbol, it doesn't have a
value. (In Common Lisp, symbols have values, but in Clojure they do
not.) In Clojure, values belong to Vars. "resolve" will find the Var
that is named by the symbol. When you w
Is there a way of invoking functions, or java methods "by name" in
Clojure?
Or, put another way, why does this work:
(+ 1 2)
but this does not:
((symbol "+") 1 2)
Similarly, this works
(. javaObj (methodName param))
but this does not:
(. javaObj ((symbol "methodName") param))
I suppose th