Re: Compiling gen-class runs static initializers: workarounds, solutions?

2017-03-28 Thread 'Gunnar Völkel' via Clojure
The JavaFX workaround consist of creating a javafx.embed.swing.JFXPanel statically in a namespace that is loaded before any other namespace that import problematic JavaFX classes as in [1,2]. This initializes the JavaFX platform. [1] https://github.com/halgari/fn-fx/blob/master/src/fn_fx/render

Re: ANN: Specter 0.11.0, performance without the tradeoffs

2016-06-02 Thread 'Gunnar Völkel' via Clojure
Following the convention not to use `def` in non-top-level positions, you should use `intern` instead of `def`. -- 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 mem

Re: Optimizing code : Fun but now paining me

2014-10-17 Thread Gunnar Völkel
I spot the following problems in your code with respect to primitive functions: 1. You declare functions (ModAdd, ...) with primitive arguments but without primitive return values. So you get boxing on the return values. 2. You pass those primtive functions as argument to EulerPowNonMemoized,

Re: Advice on managing random number generators across threads

2014-06-06 Thread Gunnar Völkel
In Java 7 you would use ThreadLocalRandom you said in another thread. Well, in Java 6 you already have ThreadLocal [1] and thus you are able to build a thread local Random yourself to keep Java 6 as minimum requirement. [1] http://docs.oracle.com/javase/6/docs/api/index.html?java/lang/ThreadLoc

Re: Allow reseeding/rebinding RNG behind rand?

2014-06-04 Thread Gunnar Völkel
Once you notice that you usually need a fast solution. The easiest solution is to just pass around an instance of java.util.Random which you create with the desired seed. Another options is to have a constructor function returning a "rand" function. (defn prng [seed] (let [rnd (java.util.Rand

Re: Licensing program written in Clojure under GPL

2014-05-12 Thread Gunnar Völkel
Program B will be released as source. So in this case I can choose the license of program B independently since it is no "derivative work" of library G? As far as I read a hint that program B is not "derivative work" of library G is that I could exchange library G with a different library which

Licensing program written in Clojure under GPL

2014-05-10 Thread Gunnar Völkel
I have written a Clojure library A which is licensed under Eclipse Public License (EPL) as usual which depends on other Clojure libraries with EPL license. In a different program B I use library A and another library G which is licensed under GPLv3. Now, the question arises which license I am a

Re: Different behaviour when using (def ^:macro ...) outside top-level

2013-09-12 Thread Gunnar Völkel
`def` does not handle `:macro true` metadata on the provided symbol. But you can work around that like clojure.core does, e.g. for the macro `defmacro` after the `(def ... defmacro ...)` call the following is called: `(. (var defmacro) (setMacro))` -- -- You received this message because you

Re: Best way to pass through named arguments (destructured map)?

2013-09-09 Thread Gunnar Völkel
You can also checkout whether my library [1] suits you. Passing option maps to other functions with options and managing doc strings for these options (transitively) are the features it was written for. It will simplify functions with options in your own code but the calls to functions of third

Re: I tripped out

2013-05-07 Thread Gunnar Völkel
You might be interested in https://github.com/guv/clojure.options/ -- -- 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 wit

Re: Parallel let form

2013-04-28 Thread Gunnar Völkel
It is not broken. It fulfills the discussed goal of having independent parallel calls in a "let"-like macro. Thus the name plet. Using a previous binding in another binding of plet was no goal. Therefore you can use the normal "let" macro. In a library one should add the intention to use it onl

Re: Performance of calling primitive type hinted functions passed as arguments

2013-04-25 Thread Gunnar Völkel
Some time ago I dug into primitive type hints and how the Clojure compiler uses them. When the compiler finds primitive type hints on a function, say (defn f [^long n] ...), the generated class for that function implements a primitive interface, IFn$LO in this case, and generates appropriate cod

Re: Problems building CounterClockwise

2013-03-02 Thread Gunnar Völkel
I wanted to point you to the developer instructions over here: http://code.google.com/p/counterclockwise/wiki/HowToBuild But apparently they changed 4 days ago. The previous description there worked for me. Try the new description there and if it fails, report an issue on that google code proje

Re: alternative to passing parameters to functions

2013-02-18 Thread Gunnar Völkel
You can checkout clojure.options (https://github.com/guv/clojure.options/). One of its main features is documentation for options (even transitive ones in calls to other functions with options). -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To

Re: Primitive function boxes and unboxes result value

2012-11-21 Thread Gunnar Völkel
Of course. You are right. I did forget about the long constant. I hope your patch will be included in Clojure 1.5. -- 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 m

Re: Primitive function boxes and unboxes result value

2012-11-21 Thread Gunnar Völkel
I think Cristophe is on the right path. But it is possible that there is another Bug concerning primitive functions. Consider the following two functions: (defn fib ^long [^long n] (if (<= n 1) 1 (+ (fib (dec n)) (fib (- n 2) (defn fib2 ^double [^double n] (if (<= n 1) 1 (+ (fib2 (dec n)

Re: Primitive function boxes and unboxes result value

2012-11-20 Thread Gunnar Völkel
I can add some additional information. I compiled the fibonacci example with double and long type hints: (defn fib ^long [^long n] (if (<= n 1) 1 (+ (fib (dec n)) (fib (- n 2) (defn fib ^double [^double n] (if (<= n 1) 1 (+ (fib (dec n)) (fib (- n 2) The one with ^long works as expe

Primitive function boxes and unboxes result value

2012-11-20 Thread Gunnar Völkel
I have written a primitive function for exponentiation with integers as power using the multiply-and-square algorithm. For performance reasons I used primitive type hints for the arguments and the return value. Profiling the whole application I noticed that there are a lot of java.lang.Double/va

Re: Possible to merge destructuring :or defaults with :as?

2012-09-03 Thread Gunnar Völkel
In case you are primarily interested in clojure functions with keyword arguments (or "optional arguments"), you might check if clojure.options (https://github.com/guv/clojure.options/) suits you. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To po

Re: Best practices for named arguments

2012-06-15 Thread Gunnar Völkel
Hello David. I have a very similar scenario according to named parameters liker you. Therefore I have written the library clojure.options which can be found here: https://github.com/guv/clojure.options The latest version is also on clojars. Greetings, Gunnar -- You received this message becaus

Re: Using JPPF in Clojure - Class Loading Issues

2012-04-04 Thread Gunnar Völkel
My first try to get JPPF to work from REPL is changing the ContextClassLoader to an implementation derived from clojure.lang.DynamicClassLoader which caches the class bytes on definition. That did not work so far. Sometimes (.setContextClassLoader (Thread/currentThread) cacheClassLoader) does no

Using JPPF in Clojure - Class Loading Issues

2012-03-29 Thread Gunnar Völkel
JPPF is a Java framework to perform distributed execution of computation jobs. In my experiment to use JPPF (http://www.jppf.org) in Clojure I noticed a class loading problem. A JPPFTask implemenation created via 'proxy could not be loaded by the JPPF framework. As a result I got the following C