clojure proxy does not re-define methods then a Java constructor is called

2013-06-12 Thread Vladimir Tsichevski
Hi,

In a Clojure proxy I need to re-define a method which is called by a Java 
constructor. I noticed that the function dispatch table in the proxy object 
is not initialized at that moment still, so the original method is always 
called.

Any suggestions?

Thanks in advance,
Vladimir

-- 
-- 
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/groups/opt_out.




Re: Java interop: Can't call public method of non-public class

2013-03-04 Thread Vladimir Tsichevski
I think not. But upgrading to clojure 1.5 will do.

On Friday, March 1, 2013 1:20:57 PM UTC+4, Marko Topolnik wrote:

 I'd say it's a bug. You are invoking a public class's method, which 
 happens to be inherited from a package-private class. Clojure's reflective 
 code accesses the superclass method directly so there's no distinction 
 between direct invocation and invocation through inheritance. 

 If you are interseted in a workaround, type-hinting the code will work (my 
 guess).

 On Friday, March 1, 2013 10:13:57 AM UTC+1, bsmith.occs wrote:

 Simplified, from a more complex example:

 abstract class Bytes {
 public toHexString() { return ...; }
 Bytes { }
 }

 public class Hash extends Bytes {
 public Hash() { super(); }
 }

 This works in Java:

 new Hash().toHexString();

 This fails in Clojure:

 (.toHexString (Hash.))

 IllegalArgumentException Can't call public method of non-public class: 
 public final java.lang.String at.gv.brz.bjuvj.hashpass.Bytes.toHexString()  
 clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88)

 Bug?

 // ben



-- 
-- 
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/groups/opt_out.




Re: how to get SHA1 of a string?

2013-03-04 Thread Vladimir Tsichevski


On Monday, March 4, 2013 10:54:13 PM UTC+4, larry google groups wrote:

 Right now I am using this block of code: 

 (let [username (get-in @um/interactions [:omniture-api- 
 credentials :username]) 
   secret (get-in @um/interactions [:omniture-api-credentials :shared- 
 secret]) 
   random-number (math/round (* (rand 1 ) 100)) 
   nonce (DigestUtils/md5Hex (str random-number)) 
   nonce-encoded-base64 (Base64/encodeBase64String (.getBytes nonce)) 
   date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss) 
   created (.format date-formatter (new Date)) 
   digest-as-string (apply str nonce created secret) 
   digest (.digest (java.security.MessageDigest/getInstance sha1) 
 (.getBytes digest-as-string)) 
   digest-base64 (Base64/encodeBase64String digest) 
   header (apply str  UsernameToken Username=\  username  \ 
 PasswordDigest=\ digest-base64 \ Nonce=\ nonce-encoded-base64 
 \ Created=\ created \)] 
 header) 

 And I get output that contains an equal sign, which I think is 
 suspect: 

 PasswordDigest=r+HWjSAk8AUvo/QmKKfbqQFnJ18= 
 Nonce=NmQxNGUwZjVlMjFhYjE1MzQ4MjUxYTA1MTg1YzE3ZTg= 

 The developer at Omniture reminded me of the characters allowed into 
 Base64: 

   You can tell a given string is base64 encoded because it can only 
 have 64 specific characters in the string: 
 A-Z 
 a-z 
 0-9 
 + 
 / 
 That's 26 + 26 + 10 + 2 = 64 
 http://en.wikipedia.org/wiki/Base64 


 I assume that means that if I see a = in the string, then it is not 
 really Base64 encoded? 


 It is. See  http://en.wikipedia.org/wiki/Base64 , the Padding section.








 On Mar 4, 1:43 pm, Craig Brozefsky cr...@red-bean.com wrote: 
  Craig Brozefsky cr...@red-bean.com writes: 
  
  .. 
  
  Sorry, didn't reaze you wanted the output to be base64 encoded, in which 
  case, add these funcs: 
  
  (defn base64-encode [^bytes v] 
(javax.xml.bind.DatatypeConverter/printBase64Binary v)) 
  
  (defn sha1-base64 [^String v] 
(- (.getBytes v) 
(sha1) 
(base64-encode))) 
  
  -- 
  Craig Brozefsky cr...@red-bean.com 
  Premature reification is the root of all evil 


-- 
-- 
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/groups/opt_out.




Why not when-let* ?

2013-02-27 Thread Vladimir Tsichevski
Hi,

The when-let macro is great, but it accepts only one binding. Why? Are 
there any reason why this macro was not ever extended to support multiple 
bindings (defined, for example, 
here: http://inclojurewetrust.blogspot.ru/2010/12/when-let-maybe.html)?

(when-let* [x (something)
y (something1)]
  (do-something x y))

Regards,
Vladimir

-- 
-- 
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/groups/opt_out.




Type hints ignored in proxy-super

2013-02-07 Thread Vladimir Tsichevski
Hi,

seems type hints are ignored when we use proxy-super:

(set! *warn-on-reflection* true)
(proxy [Object][]
  (equals[o]
(proxy-super equals)))

Reflection warning, null:3 - reference to field equals can't be resolved.

Regards,
Vladimir

PS: I'm on clojure-1.4

-- 
-- 
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/groups/opt_out.




IllegalAccessError problem when referring non-public classes

2013-02-03 Thread Vladimir Tsichevski
Hi,

I'm trying to create Excel files with jexcelapi:

https://sourceforge.net/projects/jexcelapi/files/jexcelapi

API provides a method of creating Excel fonts which uses instances of a 
non-public inner class:

  public WritableFont(FontName fn,
  int ps,
  BoldStyle bs,
  boolean it,
  UnderlineStyle us,
  Colour c)

where BoldStyle is a non-public static inner class of WritableFont.

When I'm in Java, I'm supposed to use the WritableFont.BOLD and 
WritableFont.NO_BOLD constants provided by the WritableFont class to pass 
as the 'BoldStyle bs' parameter:

  new WritableFont(WritableFont.TIMES, 16, WritableFont.BOLD, true); 

This compiles and works Ok in Java, but when I try to execute the Clojure 
equivalent:

 (WritableFont. WritableFont/TIMES 16 WritableFont/BOLD true)

it causes the following exception

java.lang.IllegalAccessError: tried to access class 
jxl.write.WritableFont$BoldStyle from class test.excel$eval775
 at test.excel$eval775.invoke (:1)
clojure.lang.Compiler.eval (Compiler.java:6511)
clojure.lang.Compiler.eval (Compiler.java:6477)
clojure.core$eval.invoke (core.clj:2797)
clojure.main$repl$read_eval_print__6405.invoke (main.clj:245)
clojure.main$repl$fn__6410.invoke (main.clj:266)
clojure.main$repl.doInvoke (main.clj:266)
clojure.lang.RestFn.invoke (RestFn.java:1096)

clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__511.invoke 
(interruptible_eval.clj:58)
clojure.lang.AFn.applyToHelper (AFn.java:159)
clojure.lang.AFn.applyTo (AFn.java:151)
clojure.core$apply.invoke (core.clj:601)
clojure.core$with_bindings_STAR_.doInvoke (core.clj:1771)
clojure.lang.RestFn.invoke (RestFn.java:425)
clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke 
(interruptible_eval.clj:43)

clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__552$fn__554.invoke
 
(interruptible_eval.clj:173)
clojure.core$comp$fn__4034.invoke (core.clj:2278)
...

Regards,
Vladimir

-- 
-- 
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/groups/opt_out.




Misleading ArityException error string

2012-12-26 Thread Vladimir Tsichevski
Hi,

if the function name has characters, which are mangled by Clojure compiler, 
and we pass to such function wrong number of argument, we got wrong error 
message. For example:

(defn a-b [x] x)
(a-b 1 2)

produces:

clojure.lang.ArityException: Wrong number of args (2) passed to: user$*a*
 at clojure.lang.AFn.throwArity (AFn.java:437)
clojure.lang.AFn.invoke (AFn.java:43)
...

Is it possible to add some de-mangling function, in order to recover the 
correct original name?

Regards,
Vladimir

-- 
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

Re: Misleading ArityException error string

2012-12-26 Thread Vladimir Tsichevski
Thanx!

On Wednesday, December 26, 2012 6:49:36 PM UTC+4, Andy Fingerhut wrote:

 Timothy Baldridge wrote a patch to improve this issue and attached it to 
 CLJ-1083:

 http://dev.clojure.org/jira/browse/CLJ-1083

 Andy

 On Dec 26, 2012, at 3:20 AM, Vladimir Tsichevski wrote:

 Hi,

 if the function name has characters, which are mangled by Clojure 
 compiler, and we pass to such function wrong number of argument, we got 
 wrong error message. For example:

 (defn a-b [x] x)
 (a-b 1 2)

 produces:

 clojure.lang.ArityException: Wrong number of args (2) passed to: user$*a*
  at clojure.lang.AFn.throwArity (AFn.java:437)
 clojure.lang.AFn.invoke (AFn.java:43)
 ...

 Is it possible to add some de-mangling function, in order to recover the 
 correct original name?

 Regards,
 Vladimir



-- 
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

Re: Interop question concerning optional args

2012-12-11 Thread Vladimir Tsichevski
I found this (mis)feature quite annoying too. I think, we all shall ask the 
language authors to fix it.

On Tuesday, December 11, 2012 10:44:34 AM UTC+4, Andy Fingerhut wrote:

 You can pass in a length 0 array of 
 java.nio.file.attribute.FileAttribute's like so:

 (java.nio.file.Files/createTempDirectory mytempname (make-array 
 java.nio.file.attribute.FileAttribute 0))

 Andy


 On Dec 10, 2012, at 8:54 PM, Dave Kincaid wrote:

 I just came across this same problem while trying to use Java 7's 
 java.nio.file.Files.createTempDirectory() 
 (http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#createTempDirectory(java.lang.String,
  
 java.nio.file.attribute.FileAttribute...))

 Clojure won't let me just do (java.nio.file.Files/createTempDirectory 
 mydir)

 It wants the FileAttribute argument. Can anyone help me get past this? I'm 
 stuck since I really can't figure out how to create a FileAttribute. Am I 
 better off just using Apache commons or something like that?

 On Monday, September 27, 2010 7:20:04 PM UTC-5, ataggart wrote:

 The vararg at the end of the method is just syntactic sugar for an 
 array, so the add method actually takes 4 args, the last being a 
 Resource array.  The java compiler just replaces missing varargs 
 with an empty array. 

 My guess is that the reflection mechanisms in the compiler just look 
 at type/arity.  The Method object has a isVarArg() boolean, so that 
 could be used to allow omitting varargs altogether.  That would need 
 to be an enhancement to the clojure compiler, so I opened a ticket: 


 https://www.assembla.com/spaces/clojure/tickets/440-java-method-calls-cannot-omit-varargs
  


 On Sep 27, 1:16 pm, JonathanBelolo jonat...@scorpiomusic.fr wrote: 
  While toying with the Sesame2.3 library, I've come across the 
  following behavior for the first time. 
  
  This is taken from the api doc for 
  org.openrdf.repository.base.RepositoryConnectionBase: 
  
  add(Resource subject, URI predicate, Value object, Resource... 
  contexts) 
Adds a statement with the specified subject, predicate and 
  object to this repository, optionally to one or more named contexts. 
  
  But apparently, Clojure seems to think the optional args are 
  mandatory... 
  
  (.add con alice RDF/TYPE person) 
  
  No matching method found: add for class 
  org.openrdf.repository.sail.SailRepositoryConnection 
[Thrown class java.lang.IllegalArgumentException] 
  
  So I run 
  
  (grep #.add (.getMethods (.getClass con))) 
  
  #Method public void 
  
 org.openrdf.repository.base.RepositoryConnectionBase.add(org.openrdf.model. 
 Resource,org.openrdf.model.URI,org.openrdf.model.Value,
 org.openrdf.model.Re source[]) 
  throws org.openrdf.repository.RepositoryException) 
  
  Finally the following works... 
  
  (.add con alice RDF/TYPE person (make-array Resource 1)) 
  nil 
  
  Is this behavior normal? Are optional args mandatory when called with 
  interop? 
  
  Thanks for your help :) 
  
  Jonathan


 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com javascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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 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

class loaders stack constant grow in REPL

2012-12-10 Thread Vladimir Tsichevski
Hi,

just found that every interaction with Clojure REPL causes one 
more DynamicClassLoader put on the Thread context class loader chain.

Here is how clojure.main/repl beginning looks like:

  (let [cl (.getContextClassLoader (Thread/currentThread))]
(.setContextClassLoader (Thread/currentThread) 
(clojure.lang.DynamicClassLoader. cl)))

And this is how to observe it:

nREPL server started on port 19987
REPL-y 0.1.0-beta10
Clojure 1.4.0
Exit: Control+D or (exit) or (quit)
Commands: (user/help)
Docs: (doc function-name-here)
  (find-doc part-of-name-here)
  Source: (source function-name-here)
  (user/sourcery function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
Examples from clojuredocs.org: [clojuredocs or cdoc]
  (user/clojuredocs name-here)
  (user/clojuredocs ns-here name-here)
user= (defn print-class-loader-stack
  ([]
 (print-class-loader-stack (.getContextClassLoader 
(Thread/currentThread
  ([cl]
 (if cl
   (do
 (pprint cl)
 (print-class-loader-stack (.getParent cl)))
   (println *Top*
  #_=   #_=   #_=   #_=   #_=   #_=   #_=   #_= 
#'user/print-class-loader-stack
user= (print-class-loader-stack)
#DynamicClassLoader clojure.lang.DynamicClassLoader@26a0c73f
#DynamicClassLoader clojure.lang.DynamicClassLoader@6f603bdc
#DynamicClassLoader clojure.lang.DynamicClassLoader@2f368c5d
#DynamicClassLoader clojure.lang.DynamicClassLoader@5b31fd9
#AppClassLoader sun.misc.Launcher$AppClassLoader@4aad3ba4
#ExtClassLoader sun.misc.Launcher$ExtClassLoader@3326b249
*Top*
nil
user= 1
1
user= 1
1
user= 1
1
user= 1
1
user= (print-class-loader-stack)
#DynamicClassLoader clojure.lang.DynamicClassLoader@5be04861
#DynamicClassLoader clojure.lang.DynamicClassLoader@7481933a
#DynamicClassLoader clojure.lang.DynamicClassLoader@273f212a
#DynamicClassLoader clojure.lang.DynamicClassLoader@4178feba
#DynamicClassLoader clojure.lang.DynamicClassLoader@5323961b
#DynamicClassLoader clojure.lang.DynamicClassLoader@26a0c73f
#DynamicClassLoader clojure.lang.DynamicClassLoader@6f603bdc
#DynamicClassLoader clojure.lang.DynamicClassLoader@2f368c5d
#DynamicClassLoader clojure.lang.DynamicClassLoader@5b31fd9
#AppClassLoader sun.misc.Launcher$AppClassLoader@4aad3ba4
#ExtClassLoader sun.misc.Launcher$ExtClassLoader@3326b249
*Top*
nil
user= 

-- 
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

Re: class loaders stack constant grow in REPL

2012-12-10 Thread Vladimir Tsichevski
Thank you Colin,

I think, the main problem is nobody has ever tried to write an article 
Class loading in Clojure. If such article existed, it would make life 
much easier for many developers.

Regards,
Vladimir

On Monday, December 10, 2012 8:32:36 PM UTC+4, Colin Jones wrote:

 Right, this is because nREPL uses clojure.main/repl each time it does an 
 evaluation. See http://dev.clojure.org/jira/browse/NREPL-31 for a related 
 issue that was addressed by modifying clojure.main/repl.

 I'm not sure where a fix for this would belong (nREPL or clojure.main), 
 but I went ahead and opened an nREPL JIRA issue to track it: 
 http://dev.clojure.org/jira/browse/NREPL-36

 - Colin




 On Monday, December 10, 2012 2:46:10 AM UTC-6, Vladimir Tsichevski wrote:

 Hi,

 just found that every interaction with Clojure REPL causes one 
 more DynamicClassLoader put on the Thread context class loader chain.

 Here is how clojure.main/repl beginning looks like:

   (let [cl (.getContextClassLoader (Thread/currentThread))]
 (.setContextClassLoader (Thread/currentThread) 
 (clojure.lang.DynamicClassLoader. cl)))

 And this is how to observe it:

 nREPL server started on port 19987
 REPL-y 0.1.0-beta10
 Clojure 1.4.0
 Exit: Control+D or (exit) or (quit)
 Commands: (user/help)
 Docs: (doc function-name-here)
   (find-doc part-of-name-here)
   Source: (source function-name-here)
   (user/sourcery function-name-here)
  Javadoc: (javadoc java-object-or-class-here)
 Examples from clojuredocs.org: [clojuredocs or cdoc]
   (user/clojuredocs name-here)
   (user/clojuredocs ns-here name-here)
 user= (defn print-class-loader-stack
   ([]
  (print-class-loader-stack (.getContextClassLoader 
 (Thread/currentThread
   ([cl]
  (if cl
(do
  (pprint cl)
  (print-class-loader-stack (.getParent cl)))
(println *Top*
   #_=   #_=   #_=   #_=   #_=   #_=   #_=   #_= 
 #'user/print-class-loader-stack
 user= (print-class-loader-stack)
 #DynamicClassLoader clojure.lang.DynamicClassLoader@26a0c73f
 #DynamicClassLoader clojure.lang.DynamicClassLoader@6f603bdc
 #DynamicClassLoader clojure.lang.DynamicClassLoader@2f368c5d
 #DynamicClassLoader clojure.lang.DynamicClassLoader@5b31fd9
 #AppClassLoader sun.misc.Launcher$AppClassLoader@4aad3ba4
 #ExtClassLoader sun.misc.Launcher$ExtClassLoader@3326b249
 *Top*
 nil
 user= 1
 1
 user= 1
 1
 user= 1
 1
 user= 1
 1
 user= (print-class-loader-stack)
 #DynamicClassLoader clojure.lang.DynamicClassLoader@5be04861
 #DynamicClassLoader clojure.lang.DynamicClassLoader@7481933a
 #DynamicClassLoader clojure.lang.DynamicClassLoader@273f212a
 #DynamicClassLoader clojure.lang.DynamicClassLoader@4178feba
 #DynamicClassLoader clojure.lang.DynamicClassLoader@5323961b
 #DynamicClassLoader clojure.lang.DynamicClassLoader@26a0c73f
 #DynamicClassLoader clojure.lang.DynamicClassLoader@6f603bdc
 #DynamicClassLoader clojure.lang.DynamicClassLoader@2f368c5d
 #DynamicClassLoader clojure.lang.DynamicClassLoader@5b31fd9
 #AppClassLoader sun.misc.Launcher$AppClassLoader@4aad3ba4
 #ExtClassLoader sun.misc.Launcher$ExtClassLoader@3326b249
 *Top*
 nil
 user= 



-- 
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

gen-class: class loading problem

2012-12-09 Thread Vladimir Tsichevski
Hi,

I'm trying embed clojure into a proprietary system.

That system can be configured to create instances of specified Java classes 
and calling specified methods.

So I want to use gen-class to create these proxies.

The only problem is that both clojure and my proprietary system handle 
class loading differently, so I need to set clojure class loader to that 
provided by the system before trying to load any application namespaces.

It would be nice to add an option to gen-class, say :use-system-loader, so 
the class created with the following declaration

(gen-class
 :name a.b.C
 :use-system-loader true)

has code generated in the very beginning of clinit method:

clojure.lang.Compiler.LOADER.bindRoot(a.b.C.getClassLoader());

to implement this feature, the following changes have be done th the 
genclass.clj:

1. The option name shall be listed among other options
2. The following block shall be added at beginning of the section for 
clinit method:

  (when use-system-loader
(doto gen
  (.getStatic (Type/getType clojure.lang.Compiler) LOADER 
var-type)
  (.push ctype)
  (.invokeVirtual class-type (Method/getMethod ClassLoader 
getClassLoader()))
  (.invokeVirtual var-type (Method/getMethod void 
bindRoot(Object)))
  ))


Regards,
Vladimir

-- 
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

CCW: compile class static method call for a class that cannot be loaded

2012-12-06 Thread Vladimir Tsichevski
Hi,

I'm using CCW to compile Clojure to java classes.

I have to compile a static class method call like this:

(MyClass/myMethod arg1 ...)


To compile this the compiler needs to load the MyClass class. The problem 
is that in my case some classes can only be loaded in the running 
application. So the compilation fails.

My current work-around is:

(clojure.lang.Reflector/invokeStaticMethod
full.name.of.MyClass
myMethod
(object-array [arg1 ...]))


Does anyone knows more elegant solution?

Regards,
Vladimir

-- 
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

Re: CCW: compile class static method call for a class that cannot be loaded

2012-12-06 Thread Vladimir Tsichevski
Hi Herwig,

thank you, you are probably right, but it writing new classes solely for 
that purpose seemes a bit too tedious task.

I found another solution: pre-load problematic classes without initializing 
them, and explicitly register them in namespaces:

(.importClass (clojure.lang.Namespace/findOrCreate 
'my.name.space)(Class/forName my.problematic.Class false 
(clojure.lang.RT/baseLoader)))


the class then may be as usual referenced as symbol in static metod call 
function (but not in macros).

IMHO it would be nice if Clojure used classes uninitialized until it is 
necessary.

Regards,
Vladimir

On Thursday, December 6, 2012 9:02:52 PM UTC+4, Herwig Hochleitner wrote:

 In clojure, as in java, you can compile against a stub class and run 
 against the real class with the same signature.


 2012/12/6 Vladimir Tsichevski tsich...@gmail.com javascript:

 Hi,

 I'm using CCW to compile Clojure to java classes.

 I have to compile a static class method call like this:

 (MyClass/myMethod arg1 ...)


 To compile this the compiler needs to load the MyClass class. The problem 
 is that in my case some classes can only be loaded in the running 
 application. So the compilation fails.

 My current work-around is:

 (clojure.lang.Reflector/invokeStaticMethod
 full.name.of.MyClass
 myMethod
 (object-array [arg1 ...]))


 Does anyone knows more elegant solution?

 Regards,
 Vladimir

 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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 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

Re: A bearded person, Clojure and JavaFX

2012-12-06 Thread Vladimir Tsichevski
Take a look at Eclipse RCP. It is much more than just a set of widgets.

On Thursday, December 6, 2012 3:38:45 AM UTC+4, Christian Sperandio wrote:

 Hi,

 I'm one of those bearded (Lin)Unixians person who love the black screen. 
 I'm closer to back-office than front-office (it's may be my (too) pragmatic 
 mind). 
 But sometimes, for some programs, a GUI is a good thing for users. In 
 particular when the sofware is not for barbed person :)
 First, I want to give details about my GUI development experience. For 
 some years now, I developed GUI with Cocoa (OS X, before IPhone and iOS 
 out). Recently, I did some development in HTML5/CSS/JS (and I hope, in the 
 future, I'll learn ClojureScript).

 Back to now, I'd like to make a GUI for a Clojure program and being in the 
 JVM world, I thought I would try a new framework: JavaFX2. Below, I give my 
 feeling and anyone can write remarks about it.

 We are living in the 2010's years and with JavaFX we find another 
 framework whose the conception is inheritance spirit. The first thing you 
 do, is a subclass of Application. Well, what do you do with delegation? 
 Composition? I had a lot of pleasure with Cocoa because there was no 
 (almost) inheritance. All your work was done by delegation. I found that 
 more elegant and cleaner. As far as I like no more the 
 Apple's philosophy (but it's another discussion), for this point I found 
 that the Cocoa's architecture was well-thought. And I find that the Clojure 
 code is damaged by the JavaFX inheritance. You must write  :gen-class 
 extends to just display a window. And when I read documentation about 
 bindings, I thought it was complicated to make a simple thing (look at 
 watch in clojure). OK, the JavaFX bindings work but I feel writing code for 
 writing code.

 My second bad point for JavaFX, it's about the interactive development. I 
 love languages like Groovy and Clojure because you can test the code in a 
 console (GroovyConsole or REPL). Can we do that with JavaFX? My main 
 problem is the following: for launching of your JavaFX application, you 
 have to call the start method in your main. It blocks the current thread 
 and the REPL waits for closing the window. While with Swing, you can create 
 components on-the-fly (no start method to display your main frame) in the 
 REPL. The thing lives and changes under your eyes. It's magic.

 Did I miss something ? Did I have a bad feeling too soon because the 
 code's weight and difficulties? When I read code like 
 callbackTableColumnPerson, String,XXX, sorry but I'm discouraged. 
 Some people laugh at Clojure because of its parentheses. But in this case, 
 we can talk about Java and its arrows.

 Finally, I think I'll turn to Swing. OK  it's less pretty and hype than 
 JavaFX but the fact I can play with Swing inside REPL is fun. And 
 seriously, why JavaFX's developers made something so unpleasant (I think 
 again this inheritance point as soon as you want to launch a simple frame).

 If some people work with JavaFX and think it's great, I'm ready to read 
 your posts. Even if I'm a bearded person, I'm ready to reassess. Perhaps, I 
 missed something.

 Chris


-- 
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

CCW and Eclipse Build Path configuration

2012-12-04 Thread Vladimir Tsichevski
Hi,

Is it possible to make CCW respect exclusions and inclusions in Eclipse 
Build Path configuration?

Regards,
Vladimir

-- 
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

Re: CCW and Eclipse Build Path configuration

2012-12-04 Thread Vladimir Tsichevski
Hi Laurent,

in Eclipse, you may configure which directories are used to look for source 
files. By default Eclipse builders try to compile all suitable files in 
these directories. So, as I understand, CCW does either.

But you may also exclude some stuff found in there from the build process 
by either defining the Exclusion pattern in the Java Build Path dialog, 
or by selecting individual files in the Project View and using the Build 
Path/Exclude popup menu item.

It would be convenient if CCW used this or some similar method to mark 
files as not-to-build.

Regards,
Vladimir

On Tuesday, December 4, 2012 4:35:23 PM UTC+4, lpetit wrote:

 Hi Vladimir, 

 2012/12/4 Vladimir Tsichevski tsich...@gmail.com javascript:: 
  Hi, 
  
  Is it possible to make CCW respect exclusions and inclusions in Eclipse 
  Build Path configuration? 

 Not sure I understand what you mean (I can think of several things you 
 may be asking). 

 Could you please elaborate a little bit more on your use case and what 
 you expect ? 
 Is this related to the lein2 support ? 

 Cheers, 

 -- 
 Laurent 


-- 
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

Re: CCW and Eclipse Build Path configuration

2012-12-04 Thread Vladimir Tsichevski

Done

On Tuesday, December 4, 2012 8:06:37 PM UTC+4, lpetit wrote:


 So, would you please create an issue for it ? I would not like to lose 
 track of it. 

 http://code.google.com/p/counterclockwise/issues/list 

 Thanks, 

 -- 
 Laurent 


-- 
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

Re: Change the CCW compile output catalog

2012-12-02 Thread Vladimir Tsichevski
You aswers had everything I needed to know to move forward. Did not notice 
anything strange in them. It were late hours here in Moscow thought :-)

On Sunday, December 2, 2012 2:32:45 AM UTC+4, lpetit wrote:

 2012/12/1 Laurent PETIT lauren...@gmail.com javascript:: 
  Hello, 
  
  2012/12/1 Vladimir Tsichevski tsich...@gmail.com javascript:: 
  Hi, 
  
  CCW always outputs compiled classes into the classes catalog. AFAIK, 
 this 
  name is compiled into CCW and hence cannot be changed. My two questions 
 are: 
  
  1. Why the catalog path is not configurable? Was this made 
 intentionally? 
  
  It is a limitation, for sure, which comes from the past. Will 
  eventually go. There's not reason for it to not be configurable, but 
  no having dedicated time to do so. 
  
  2. Why this catalog differs from the Java output catalog? Was it made 
  intentionally, or it is Ok to put all project output classes to same 
  catalog? 
  
  Yes, it is intentional that CCW's output is not in the same folder 
  hierarchy as other Java output. 
  Indeed, it's not possible (or sufficiently complex to have been 
  considered so) to inform Eclipse (which manages java source/classes 
  via the JDT - Java Development Tools-) that there are contents in the 
  same output as where it compiles classes, and that it would be polite 
  not to erase the folder content as if it were under its full control. 
  
  Now, beyond your interesting in understand why things are how they 
  are, I'd be interesting in knowing if that's currently getting in your 
  way, and if so, try to see  if I can help you find a workaround until 
  this is eventually customizable. 

 Wow, re-reading myself right now. Either I was drunk, or the 
 spellchecker cheated on me a lot :-) 

  
  
  HTH, 
  
  -- 
  Laurent 


-- 
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

Re: class loading problem in embedded clojure

2012-12-01 Thread Vladimir Tsichevski
Hi,

nobody still cannot explain why

PlatformUI (PlatformUI/getWorkbench)

works, and

(PlatformUI/getWorkbench)

does not?

-- 
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

Change the CCW compile output catalog

2012-12-01 Thread Vladimir Tsichevski
Hi,

CCW always outputs compiled classes into the classes catalog. AFAIK, this 
name is compiled into CCW and hence cannot be changed. My two questions are:

1. Why the catalog path is not configurable? Was this made intentionally?
2. Why this catalog differs from the Java output catalog? Was it made 
intentionally, or it is Ok to put all project output classes to same 
catalog?

Regards,
Vladimir

-- 
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

Re: Change the CCW compile output catalog

2012-12-01 Thread Vladimir Tsichevski

Hi Laurent,

many thanks for the quick and helpful response!

Now that I've managed to make CCW compile my clojure code to classes I'm 
wondering how to tell Eclipse to package these classes to an RCP plugin 
along with classes produced from Java.

Regards,
Vladimir

On Sunday, December 2, 2012 1:04:06 AM UTC+4, lpetit wrote:

 Hello, 

 2012/12/1 Vladimir Tsichevski tsich...@gmail.com javascript:: 
  Hi, 
  
  CCW always outputs compiled classes into the classes catalog. AFAIK, 
 this 
  name is compiled into CCW and hence cannot be changed. My two questions 
 are: 
  
  1. Why the catalog path is not configurable? Was this made 
 intentionally? 

 It is a limitation, for sure, which comes from the past. Will 
 eventually go. There's not reason for it to not be configurable, but 
 no having dedicated time to do so. 

  2. Why this catalog differs from the Java output catalog? Was it made 
  intentionally, or it is Ok to put all project output classes to same 
  catalog? 

 Yes, it is intentional that CCW's output is not in the same folder 
 hierarchy as other Java output. 
 Indeed, it's not possible (or sufficiently complex to have been 
 considered so) to inform Eclipse (which manages java source/classes 
 via the JDT - Java Development Tools-) that there are contents in the 
 same output as where it compiles classes, and that it would be polite 
 not to erase the folder content as if it were under its full control. 

 Now, beyond your interesting in understand why things are how they 
 are, I'd be interesting in knowing if that's currently getting in your 
 way, and if so, try to see  if I can help you find a workaround until 
 this is eventually customizable. 


 HTH, 

 -- 
 Laurent 


-- 
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

Re: Change the CCW compile output catalog

2012-12-01 Thread Vladimir Tsichevski

On Sunday, December 2, 2012 2:11:48 AM UTC+4, Vladimir Tsichevski wrote:


 Hi Laurent,

 many thanks for the quick and helpful response!

 Now that I've managed to make CCW compile my clojure code to classes I'm 
 wondering how to tell Eclipse to package these classes to an RCP plugin 
 along with classes produced from Java.

Just found the answer. Please, ignore my question. 


 Regards,
 Vladimir

 On Sunday, December 2, 2012 1:04:06 AM UTC+4, lpetit wrote:

 Hello, 

 2012/12/1 Vladimir Tsichevski tsich...@gmail.com: 
  Hi, 
  
  CCW always outputs compiled classes into the classes catalog. AFAIK, 
 this 
  name is compiled into CCW and hence cannot be changed. My two questions 
 are: 
  
  1. Why the catalog path is not configurable? Was this made 
 intentionally? 

 It is a limitation, for sure, which comes from the past. Will 
 eventually go. There's not reason for it to not be configurable, but 
 no having dedicated time to do so. 

  2. Why this catalog differs from the Java output catalog? Was it made 
  intentionally, or it is Ok to put all project output classes to same 
  catalog? 

 Yes, it is intentional that CCW's output is not in the same folder 
 hierarchy as other Java output. 
 Indeed, it's not possible (or sufficiently complex to have been 
 considered so) to inform Eclipse (which manages java source/classes 
 via the JDT - Java Development Tools-) that there are contents in the 
 same output as where it compiles classes, and that it would be polite 
 not to erase the folder content as if it were under its full control. 

 Now, beyond your interesting in understand why things are how they 
 are, I'd be interesting in knowing if that's currently getting in your 
 way, and if so, try to see  if I can help you find a workaround until 
 this is eventually customizable. 


 HTH, 

 -- 
 Laurent 



-- 
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

class loading problem in embedded clojure

2012-11-30 Thread Vladimir Tsichevski
Hi,

I've embedded Clojure 1.4 with nREPL into my Eclipse RCP application.

Now in nREPL I define a function which builds a menu with some actions. 
Everything seemes to work as expected.
Now I select some menu item which executes the following code:

  (println PlatformUI)
  (println (PlatformUI/getWorkbench))

where 'PlatformUI' is a class from Eclipse base distribution imported 
earlier in the ns declaration, and 'getWorkbench' is its static method. 
This code works Ok also.

Now I remove the first line and run just

  (println (PlatformUI/getWorkbench))

And got the exception below. Anybody can explain this?

java.lang.NoClassDefFoundError: org/eclipse/ui/PlatformUI
at myApp.clojure.menu$menu$fn__1475.invoke(Unknown Source)
at myApp.clojure.menu.proxy$org.eclipse.jface.action.Action$0.run(Unknown 
Source)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at 
myApp.clojure.menu.proxy$org.eclipse.jface.action.Action$0.runWithEvent(Unknown 
Source)
at 
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at 
org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at 
org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3588)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3209)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at 
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at 
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at myApp.rcp.MyAppApp.start(MyAppApp.java:24)
at 
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at 
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at 
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at 
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at 
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: java.lang.ClassNotFoundException: org.eclipse.ui.PlatformUI
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 32 more

-- 
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

Re: call superclass method in classes created by Clojure?

2012-11-30 Thread Vladimir Tsichevski
Thank you David, it works!

On Thursday, November 29, 2012 5:44:06 PM UTC+4, David Powell wrote:

 proxy is basically a more interop-oriented version of reify though, and it 
 can extend classes, and you can use proxy-super to call superclass methods 
 from there.
 On Nov 29, 2012 1:40 PM, Vladimir Tsichevski 
 tsich...@gmail.comjavascript: 
 wrote:

 Thanks

 On Thursday, November 29, 2012 5:33:20 PM UTC+4, David Powell wrote:


 reify can only implement interfaces and protocols, so there aren't any 
 superclass methods to call (except the ones in Object I guess).


 On Thu, Nov 29, 2012 at 1:30 PM, Vladimir Tsichevski tsich...@gmail.com
  wrote:

 Thanks,

 is there something like that for reify?


 On Thursday, November 29, 2012 2:52:56 AM UTC+4, Meikel Brandmeyer 
 (kotarak) wrote:

 Am 28.11.12 23:10, schrieb Vladimir Tsichevski: 
  Is it possible? 
 See exposes-methods in documentation for gen-class. 

 http://clojure.github.com/**cloj**ure/clojure.core-api.html#**cloj**
 ure.core/gen-classhttp://clojure.github.com/clojure/clojure.core-api.html#clojure.core/gen-class
  

 Kind regards 
 Meikel 

  -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@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+u...@**googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en


  -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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 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

Re: call superclass method in classes created by Clojure?

2012-11-29 Thread Vladimir Tsichevski
Thanks,

is there something like that for reify?

On Thursday, November 29, 2012 2:52:56 AM UTC+4, Meikel Brandmeyer 
(kotarak) wrote:

 Am 28.11.12 23:10, schrieb Vladimir Tsichevski: 
  Is it possible? 
 See exposes-methods in documentation for gen-class. 


 http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/gen-class
  

 Kind regards 
 Meikel 



-- 
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

Re: call superclass method in classes created by Clojure?

2012-11-29 Thread Vladimir Tsichevski
Thanks

On Thursday, November 29, 2012 5:33:20 PM UTC+4, David Powell wrote:


 reify can only implement interfaces and protocols, so there aren't any 
 superclass methods to call (except the ones in Object I guess).


 On Thu, Nov 29, 2012 at 1:30 PM, Vladimir Tsichevski 
 tsich...@gmail.comjavascript:
  wrote:

 Thanks,

 is there something like that for reify?


 On Thursday, November 29, 2012 2:52:56 AM UTC+4, Meikel Brandmeyer 
 (kotarak) wrote:

 Am 28.11.12 23:10, schrieb Vladimir Tsichevski: 
  Is it possible? 
 See exposes-methods in documentation for gen-class. 

 http://clojure.github.com/**clojure/clojure.core-api.html#**
 clojure.core/gen-classhttp://clojure.github.com/clojure/clojure.core-api.html#clojure.core/gen-class
  

 Kind regards 
 Meikel 

  -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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 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

call superclass method in classes created by Clojure?

2012-11-28 Thread Vladimir Tsichevski
Is it possible?

-- 
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

Re: How to add an URL into the classpath?

2012-11-21 Thread Vladimir Tsichevski
Hi Yoshinori,

after (unsuccessfully) struggling with Clojure dynamic ClassLoaders in 
clojure-1.4, I ended up with the 'brute force' solution--just add URL 
entries to the Java system classloader. Here is a simple example on how to 
do it from clojure:

(defn add-system-classpath
  Add an url path to the system class loader
  [url-string]
  (let [field (aget (.getDeclaredFields java.net.URLClassLoader) 0)]
(.setAccessible field true)
(let [ucp (.get field (ClassLoader/getSystemClassLoader))]
  (.addURL ucp (java.net.URL. url-string)

(add-system-classpath file:/some/clojure/root/)
(load some/clojure/file) ;; load the some/clojure/file.clj from the 
/some/clojure/root/ catalog
(add-system-classpath file:/some/java/classes/)
some.java.MyClass ;; use the some.java.MyClass in the /some/java/classes/ 
catalog

Regards,
Vladimir

-- 
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

Run Counterclockwise nREPL on specific port

2012-11-20 Thread Vladimir Tsichevski
Hi,

I've started a nREPL process embedded into some Java application. I can 
successfully connect to it and execute code remotely from other Clojure 
process.

Now I need a client to provide me interactive REPL session. Since I use 
Counterclockwise, can I force Counterclockwise not to start a Closure 
project, but connect to a remote application already listening at some 
known port?

Regards,
Vladimir

-- 
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

Re: Run Counterclockwise nREPL on specific port

2012-11-20 Thread Vladimir Tsichevski
Hi Jim,

On Tuesday, November 20, 2012 10:13:02 PM UTC+4, Jim foo.bar wrote:

 On 20/11/12 18:08, Vladimir Tsichevski wrote: 
  I've started a nREPL process embedded into some Java application. I 
  can successfully connect to it and execute code remotely from other 
  Clojure process. 

 I'd be very interested if you could share some code...I want to do 
 something similar in one of my projects... 

Not much of code at the moment, mostly taken from an example on nREPL 
project page:

 String str = (use '[clojure.tools.nrepl.server :only (start-server 
stop-server)])(defonce server (start-server :port 7888));
 Compiler.load(new StringReader(text));


  Now I need a client to provide me interactive REPL session. Since I 
  use Counterclockwise, can I force Counterclockwise not to start a 
  Closure project, but connect to a remote application already listening 
  at some known port? 

 CCW has a 'connect to repl' option under  'Window'. It asks doe an IP 
 and a port number...is this what you're looking for? 

Exactly! The menu location is quite unusual for Eclipse :-(


 Jim 



-- 
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

Re: impossible to create classes for non-closure environment

2012-11-05 Thread Vladimir Tsichevski

Hi Stuart.

thank you for pointing me to my 'cloSure' misspelling. Have lived in the 
Scheme world for too long :-)

As to Java classes generation, IMHO it is more save to generate Java 
bytecode directly instead of using intermediate Java sources. This is how I 
create classes now using a generator written in Java. Now I have to 
re-write this generator in CloJure.

Regards,
Vladimir

On Monday, November 5, 2012 1:09:11 AM UTC+4, Stuart Sierra wrote:

 Hello,

 Clojure (by the way, it is not spelled closure) is not really designed 
 to generate pure-Java classes. `gen-class` is slightly more flexible than 
 `deftype`, but it will still generate references to Clojure classes.

 If the structure of your Java classes is defined by interfaces, `deftype` 
 can implement those interfaces. But if the structure of the Java classes is 
 very regular, you may find it easier to generate Java source code as 
 strings. That's how all the primitive interfaces in clojure.lang.IFn were 
 created.

 -S



 On Sunday, November 4, 2012 4:43:59 AM UTC-5, Vladimir Tsichevski wrote:

 Thank you Stephen,

 the problem is that it is impossible to create create a Java class using 
 closure with the following characteristics:

 1) all methods must match given Java signature. For example, if I need a 
 method

 public String getSomeString();

 all I get is

 public Object getSomeString();

 closure ignores my String hints and always uses Object instead.

 2) must be no references to any closure classes. Now the closure compiler 
 unconditionally creates at least one extra method

 public static IPersistentVector getBasis()

 which references several classes from closure runtime.

 Regards,
 Vladimir

 On Sat, 2012-11-03 at 13:57 -0700, Vladimir Tsichevski wrote: 
  In one of my purely Java project I have to create hundreds of java 
 classes 
  with repeatable structure, so the task is an excellent candidate for 
  automation. I hoped I will be able to create these classes with the 
 latest 
  closure, using the 'deftype' construct. 

 If you know all the details of classes to create at compile time, you 
 can use macros instead, which are perfectly well able to output deftype 
 forms.  Untested: 

 (defmacro defrefs 
   Make a bunch of :x boxes. 
   [ names] 
   `(do ~@(map (fn [name] `(defrecord ~name [~'x])) names))) 

 ;; makes classes foo, bar, baz, qux, quux, all with the :x field. 
 (defrefs foo bar baz qux quux) 

 -- 
 Stephen Compall 
 ^aCollection allSatisfy: [:each|aCondition]: less is better 




-- 
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

Re: impossible to create classes for non-closure environment

2012-11-05 Thread Vladimir Tsichevski
Thanks Nicolas,

may be you are right, and I'll end up with Kawa or Bigloo. I just evaluate 
Clojure, trying to find out if it fits to my goals.

On Monday, November 5, 2012 1:40:10 PM UTC+4, Nicolas Oury wrote:

 I am not sure it will help, but have you tried Kawa?
 It is a Scheme compiling to the JVM, with support for macro as well and 
 seems to be lower level than Clojure, which might help with your task.


 I know. I used Kawa back in 2004. I even mentioned in the Kawa 
acknowledgements  http://www.gnu.org/software/kawa/Acknowledgements.html :-)

On Mon, Nov 5, 2012 at 9:07 AM, Vladimir Tsichevski 
tsich...@gmail.comjavascript:
  wrote:


 Hi Stuart.

 thank you for pointing me to my 'cloSure' misspelling. Have lived in the 
 Scheme world for too long :-)

 As to Java classes generation, IMHO it is more save to generate Java 
 bytecode directly instead of using intermediate Java sources. This is how I 
 create classes now using a generator written in Java. Now I have to 
 re-write this generator in CloJure.

 Regards,
 Vladimir

 On Monday, November 5, 2012 1:09:11 AM UTC+4, Stuart Sierra wrote:

 Hello,

 Clojure (by the way, it is not spelled closure) is not really designed 
 to generate pure-Java classes. `gen-class` is slightly more flexible than 
 `deftype`, but it will still generate references to Clojure classes.

 If the structure of your Java classes is defined by interfaces, 
 `deftype` can implement those interfaces. But if the structure of the Java 
 classes is very regular, you may find it easier to generate Java source 
 code as strings. That's how all the primitive interfaces in 
 clojure.lang.IFn were created.

 -S



 On Sunday, November 4, 2012 4:43:59 AM UTC-5, Vladimir Tsichevski wrote:

 Thank you Stephen,

 the problem is that it is impossible to create create a Java class 
 using closure with the following characteristics:

 1) all methods must match given Java signature. For example, if I need 
 a method

 public String getSomeString();

 all I get is

 public Object getSomeString();

 closure ignores my String hints and always uses Object instead.

 2) must be no references to any closure classes. Now the closure 
 compiler unconditionally creates at least one extra method

 public static IPersistentVector getBasis()

 which references several classes from closure runtime.

 Regards,
 Vladimir

 On Sat, 2012-11-03 at 13:57 -0700, Vladimir Tsichevski wrote: 
  In one of my purely Java project I have to create hundreds of java 
 classes 
  with repeatable structure, so the task is an excellent candidate for 
  automation. I hoped I will be able to create these classes with the 
 latest 
  closure, using the 'deftype' construct. 

 If you know all the details of classes to create at compile time, you 
 can use macros instead, which are perfectly well able to output 
 deftype 
 forms.  Untested: 

 (defmacro defrefs 
   Make a bunch of :x boxes. 
   [ names] 
   `(do ~@(map (fn [name] `(defrecord ~name [~'x])) names))) 

 ;; makes classes foo, bar, baz, qux, quux, all with the :x field. 
 (defrefs foo bar baz qux quux) 

 -- 
 Stephen Compall 
 ^aCollection allSatisfy: [:each|aCondition]: less is better 


  -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en




 -- 
 Sent from an IBM Model M, 15 August 1989.
  

-- 
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

Re: impossible to create classes for non-closure environment

2012-11-04 Thread Vladimir Tsichevski
Thank you Stephen,

the problem is that it is impossible to create create a Java class using 
closure with the following characteristics:

1) all methods must match given Java signature. For example, if I need a 
method

public String getSomeString();

all I get is

public Object getSomeString();

closure ignores my String hints and always uses Object instead.

2) must be no references to any closure classes. Now the closure compiler 
unconditionally creates at least one extra method

public static IPersistentVector getBasis()

which references several classes from closure runtime.

Regards,
Vladimir

On Sat, 2012-11-03 at 13:57 -0700, Vladimir Tsichevski wrote: 
  In one of my purely Java project I have to create hundreds of java 
 classes 
  with repeatable structure, so the task is an excellent candidate for 
  automation. I hoped I will be able to create these classes with the 
 latest 
  closure, using the 'deftype' construct. 

 If you know all the details of classes to create at compile time, you 
 can use macros instead, which are perfectly well able to output deftype 
 forms.  Untested: 

 (defmacro defrefs 
   Make a bunch of :x boxes. 
   [ names] 
   `(do ~@(map (fn [name] `(defrecord ~name [~'x])) names))) 

 ;; makes classes foo, bar, baz, qux, quux, all with the :x field. 
 (defrefs foo bar baz qux quux) 

 -- 
 Stephen Compall 
 ^aCollection allSatisfy: [:each|aCondition]: less is better 




-- 
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

Java-to-Clojure source translation?

2012-11-04 Thread Vladimir Tsichevski
Hi gurus,

I wonder if there are any means that'd help me translate Java sources to 
Clojure? I do not expect getting working Closure code OOTB, just anything 
to start from.

Regards,
Vladimir

-- 
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

Re: Java-to-Clojure source translation?

2012-11-04 Thread Vladimir Tsichevski
Hi Maik,

no, I need to re-implement existing code in Clojure.

Why do you want this? If you have java code you can just call it from 
 clojure.no need for translation
  Am 04.11.2012 19:39 schrieb Vladimir Tsichevski 
 tsich...@gmail.comjavascript:
 :

 Hi gurus,

 I wonder if there are any means that'd help me translate Java sources to 
 Clojure? I do not expect getting working Closure code OOTB, just anything 
 to start from.

 Regards,
 Vladimir

 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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 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

pattern-matching in Closure?

2012-11-04 Thread Vladimir Tsichevski
Hi gurus.

Is it possible in Clojure to use pattern matching, like I can with Bigloo 
scheme, for example:

(match-case '(a b a)
  ((?x ?x) 'foo)
  ((?x ?- ?x) 'bar))

Regards,
Vladimir

-- 
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

Re: Java-to-Clojure source translation?

2012-11-04 Thread Vladimir Tsichevski
Hi Stuart.

On Monday, November 5, 2012 1:10:36 AM UTC+4, Stuart Sierra wrote:

 Hello,

 It is not really possible to make a direct translation from Java to 
 Clojure. Java has mutable variables and imperative flow-control, for which 
 there is no equivalent in Clojure.

 -S

  That's why I'm looking for means which could HELP me rewrite my code base 
to Clojure, not to produce compilable and runnable code. Just parse Java 
syntax tree and pretty-print it back as Clojure-like text.

Regards,
Vladimir


-- 
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

Re: pattern-matching in Closure?

2012-11-04 Thread Vladimir Tsichevski
Hi Moritz,

this looks promising. Do you know where can I get any 
documentation/examples for this module?

Regards,
Vladimir

On Monday, November 5, 2012 1:10:59 AM UTC+4, Moritz Ulrich wrote:

 Use core.match: https://github.com/clojure/core.match 

 On Sun, Nov 4, 2012 at 10:09 PM, Vladimir Tsichevski 
 tsich...@gmail.com javascript: wrote: 
  Hi gurus. 
  
  Is it possible in Clojure to use pattern matching, like I can with 
 Bigloo 
  scheme, for example: 
  
  (match-case '(a b a) 
((?x ?x) 'foo) 
((?x ?- ?x) 'bar)) 
  
  Regards, 
  Vladimir 
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.comjavascript: 
  Note that posts from new members are moderated - please be patient with 
 your 
  first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@googlegroups.com javascript: 
  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 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

Re: pattern-matching in Closure?

2012-11-04 Thread Vladimir Tsichevski
Excellent! Thanks!

On Monday, November 5, 2012 2:12:16 AM UTC+4, Marek Šrank wrote:

 At the wiki: https://github.com/clojure/core.match/wiki :-)

 Marek.

 On Sunday, November 4, 2012 11:03:40 PM UTC+1, Vladimir Tsichevski wrote:

 Hi Moritz,

 this looks promising. Do you know where can I get any 
 documentation/examples for this module?

 Regards,
 Vladimir

 On Monday, November 5, 2012 1:10:59 AM UTC+4, Moritz Ulrich wrote:

 Use core.match: https://github.com/clojure/core.match 

 On Sun, Nov 4, 2012 at 10:09 PM, Vladimir Tsichevski 
 tsich...@gmail.com wrote: 
  Hi gurus. 
  
  Is it possible in Clojure to use pattern matching, like I can with 
 Bigloo 
  scheme, for example: 
  
  (match-case '(a b a) 
((?x ?x) 'foo) 
((?x ?- ?x) 'bar)) 
  
  Regards, 
  Vladimir 
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@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+u...@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 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

impossible to create classes for non-closure environment

2012-11-03 Thread Vladimir Tsichevski
Hi closure developers.

In one of my purely Java project I have to create hundreds of java classes 
with repeatable structure, so the task is an excellent candidate for 
automation. I hoped I will be able to create these classes with the latest 
closure, using the 'deftype' construct.

I learned currently it is impossible to do that with closure.

Is that functionality planned for future releases? What is the correct 
place to ask for clojure improvements?

Regards,
Vladimir

-- 
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