You Right! BUT still does not work. I tried:
Var type = RT.var("clojure.core","type"); Object oType = type.invoke("employee"); Var struct = RT.var("clojure.core", "struct-map"); Object oStruct = struct.invoke(oType,"Diego",26,"Coach",1000); Var hire = RT.var("user", "hire"); Object r = hire.invoke(oStruct); System.out.println(r); ...... I got the exception: java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.PersistentStructMap$Def at clojure.core$struct_map.doInvoke(core.clj:3128) at clojure.lang.RestFn.invoke(RestFn.java:486) at clojure.lang.Var.invoke(Var.java:381) at com.github.diegopacheco.sandbox.java.clojure.JavaCallsClojureInterpreted.main(JavaCallsClojureInterpreted.java: 42) ............. When I do: Var struct = RT.var("clojure.core", "create- struct"); Object oStruct = struct.invoke("employee","Diego",26,"Coach", 1000); Var hire = RT.var("user", "hire"); Object r = hire.invoke(oStruct); System.out.println(r); Var printee = RT.var("user", "print-employee"); Object r2 = printee.invoke(oStruct); System.out.println(r2); Var print = RT.var("user", "print-employees"); Object result = print.invoke(); System.out.println(result); ............ I GOT: [#<Def clojure.lang.PersistentStructMap$Def@6b6ac8>] "Name: - Age: - Role: - Salary:" null "Name: - Age: - Role: - Salary:" clojure.lang.LazySeq@1f ........... When I DO: Var struct = RT.var("clojure.core", "create-struct"); Object oStruct = struct.invoke("employee","Diego",26,"Coach", 1000); Var employee = RT.var("clojure.core", "struct"); Object oEmployee = employee.invoke(oStruct); Var hire = RT.var("user", "hire"); Object r = hire.invoke(oEmployee); System.out.println(r); Var printee = RT.var("user", "print-employee"); Object r2 = printee.invoke(oEmployee); System.out.println(r2); Var print = RT.var("user", "print-employees"); Object result = print.invoke(); System.out.println(result); ....... I Got: [{"employee" nil, "Diego" nil, 26 nil, "Coach" nil, 1000 nil}] "Name: - Age: - Role: - Salary:" null "Name: - Age: - Role: - Salary:" clojure.lang.LazySeq@1f I'm loosing my hope, does anybody used this feature before ? Any idea what I'm doing wrong ? Cheers, @diego_pacheco On Oct 14, 3:58 am, Alexander Taggart <m...@ataggart.ca> wrote: > I suspect this... > > Var struct = RT.var("clojure.core", "struct","employee :diego 10 :coach > 1000"); > > isn't doing what you think it will. That will set the root binding of > clojure.core/struct to the string you gave it. you probably want to get the > var for the struct function, and then invoke it with the arguments to create > an employee struct instance. -- 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