I can't directly help you with C#, but I think the problem here is not
related to the host platform, and the code snippet below (which is in Java)
should be easy enough to translate.

It's a bit tricky because def is not actually a function and can thus not
be accessed from Java (or C#) using the official API.

Fortunately, the function clojure.core/intern does what you want: bind a
new value to a symbol.

(If you want to access the value from Java/C#, you also have to manually
unpack it from the Var as shown below.)


package temp;

import clojure.java.api.Clojure;
import clojure.lang.IFn;

public class TestInterop {
    public static void main(String[] args) {
        IFn intern = Clojure.var("clojure.core", "intern");
        IFn symbol = Clojure.var("clojure.core", "symbol");
        IFn println = Clojure.var("clojure.core", "println");
        IFn var_get = Clojure.var("clojure.core", "var-get");


        // Bind the hello symbol in the user namespace
        intern.invoke(symbol.invoke("user"),
                      symbol.invoke("hello"),
                      4);

        IFn my_var = Clojure.var("user", "hello");


        // Print the actual var associated to the symbol hello in ns user
        println.invoke(my_var);
        // Print the value associated to the var
        println.invoke(var_get.invoke(my_var));
    }
}


Please do note, however, that I believe you might be approaching the
problem from a weird angle, as it would probably be much easier to define
an atom in Clojure and expose a function that sets its value.


On 12 November 2014 19:25, rvdalen <rouan.van.da...@gmail.com> wrote:

> Hi,
>
> I have a basic editor, which uses clojure-clr as a lib.
>
> I need to pass a C# value into an instance of clojure-clr, using the
> clojure-clr C# api.
>
> I tried something like:
>
>              Symbol s = Symbol.intern("*appState*");
>
>             IFn def = Clojure.var( "clojure.core", "def" );
>             def.invoke( s, appState );
>
> but it complains about the arguments to def.
>
> Can anyone point me in the right direction here please.
>
> I know clojure-clr has its own mailing list, but I could not get an answer
> there, and the
> Java & C# api should be almost identical
>
> regards
> --Rouan
>
> --
> 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 be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to