Re: gen-class: override only 1 method of an arity-overloaded method of a (Java) superclass

2016-01-05 Thread Kurt Sys
Yeah... I actually wanted to avoid that - I don't really want to 
(publically) 'expose' them. It means I have to expose all arity-overloaded 
methods I want to use, and in some libraries, there are quite a lot of 
these. It just feels a bit weird to publically expose (protected) methods 
of superclasses - well, we're using classes here, so I do think in 
inheritance-based oop for this example.

Anyway, exposing is probably how to do it...

thanks, qsys

Op maandag 28 december 2015 04:22:36 UTC+1 schreef James Elliott:
>
> I don’t have a ton of experience with gen-class, but I think you need to 
> tell it to expose the superclass methods you want to call using 
> :exposes-methods, as described in 
> http://stackoverflow.com/questions/9060127/how-to-invoke-superclass-method-in-a-clojure-gen-class-method
>
> In case it is of any use, here is an example of where I successfully 
> subclassed a Java class from an external library and called some superclass 
> methods: 
> https://github.com/brunchboy/afterglow-max/blob/master/src/afterglow/max/Var.clj
>
> On Wednesday, December 23, 2015 at 3:23:41 AM UTC-6, Kurt Sys wrote:
>>
>> When using gen-class and arity-overloaded methods of a superclass seems 
>> not very obvious, or I am missing something...
>>
>> There's a (java) superclass 'some.Superclass' (which is from a library, 
>> so I can't change this one):
>>
>> public abstract class Superclass {
>>public void method() {
>>}
>>
>>public void method(Object something) {
>>   this.method();
>>   // other logic
>>}
>> }
>>
>>
>> I want to extend that base (abstract) class in clojure, using gen-class 
>> (since the class needs to accessible as a normal Java class). So the first 
>> thing I did was:
>>
>> (ns my.namespace
>>   (:gen-class
>>:name "my.namespace.ArityTest"
>>:extends some.Superclass
>>:prefix "some-")
>>  )
>>
>> (defn some-method
>>   [this]
>>   (println "1-arity"))
>>
>> However, this doesn't work: 'method' is arity-overloaded, when calling 
>> new ArityTest().method(new Object())
>>
>> I get a ArityException, wrong number of arguments (2). I suppose this is 
>> because I override 'method', so I have to override all arities? I'd like to 
>> have the 1-arity version to call it's superclass method, and I seem to fail 
>> at that. The last attempt is this: get the method of the superclass and 
>> call that method on 'this':
>>
>> (ns be.admb.kbf.vertx.shell.test
>> (:gen-class
>>   :name "my.namespace.ArityTest"
>>   :extends some.Superclass
>>   :prefix "some-")
>> )
>>
>>
>> (defn some-method
>>   ([this]
>> (println "1-arity"))
>>   ([this o]
>> (.invoke (-> this
>>  (.getClass)
>>  (.getSuperclass)
>>  (.getMethod "method"
>>  (into-array Class [java.lang.Object])))
>>  this (into-array Object [o]))
>> ))
>>
>> This fails: it calls the overriden method, not the superclass' method... 
>> (and the method keeps on calling itself).
>>
>> The question: how do I override only 1 method of an arity-overloaded 
>> method of a superclass in Clojure (using gen-class to generate a Java 
>> class)?
>>
>

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


Re: Compare between clojure and Java

2016-01-05 Thread Gregg Reynolds
On Jan 5, 2016 7:49 AM, "gvim"  wrote:
>
> On 05/01/2016 13:44, Josh Kamau wrote:
>>
>> Here is an extremely simple example:
>>
>> Problem: add a list of numbers
>>
>> java: You put something like this in a class in a method
>>
>> int[] numbers = {1,2,3,4,5,6,7,7,8,4,3} ;
>>
>> int sum = 0 ;
>> for(int i = 0; i < sum.length; i++) {
>>  sum = sum + i;
>> }
>>
>> return sum;
>>
>>
>> clojure: You put this in a clojure namespace
>>
>> (def numbers [1 2 3 4 54 56 6])
>>
>> ;;to get the sum
>> (reduce + numbers)
>>
>>
>> You get the idea ;)
>>
>> Josh
>>
>>
>
> Or simply:
>
> (reduce + [1 2 3 4 54 56 6])
>
Or  (+ 1 2 3 4 54 56 6)

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


Re: lein cljsbuild once works, but another build method doesn't -- ?

2016-01-05 Thread James Elliott
Indeed. If your project has dependencies that are being managed by 
Leiningen, you probably want to use Leiningen to run it (so that the 
classpath can be set properly to include all those dependencies; it can vet 
very long), or tell Leiningen to build an uberjar that embeds both your 
code and all of the dependencies. Then you can run that simply with java 
-jar

https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md#running-code

https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md#uberjar

  -James

On Monday, December 28, 2015 at 5:10:35 PM UTC-6, Erik Price wrote:
>
> The -cp flag should be passed a colon-separated list of entires to search 
> for dependency code. Each entry in the list can be either a directory (in 
> which case the contents of the directory must immediately contain Java or 
> Clojure source files) or a JAR file. So the command you’re currently using 
> says “look for dependencies in the cljs.jar file and the src directory”.
>
> Leiningen downloads and locally caches the dependencies you list in your 
> project.clj for you. If you’re sure those dependencies have already been 
> downloaded to your system, try including the paths to those dependencies’ 
> JAR files in your -cp argument.
>
> e
> ​
>
> On Mon, Dec 28, 2015 at 5:54 PM,  wrote:
>
>> hi
>>
>> I have a ClojureScript project. It builds successfully with lein 
>> cljsbuild once and I'm able to run my program on node.
>>
>> I'm trying to follow the QuickStart guide for getting a node REPL.
>>
>> I have node.clj
>> (require 'cljs.build.api)
>>
>> (cljs.build.api/build "src"
>>   {:main 'hello-world.core
>>:output-to "main.js"
>>:target :nodejs})
>>
>> But when I run java -cp cljs.jar:src clojure.main node.clj
>>
>> It says: No such namespace and refers to a dependency that I've listed in 
>> project.clj. Do I need to add something to the -cp argument when I call 
>> java? 
>>
>> Thanks in advance for any help!
>>
>> -- 
>> 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 unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@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.


Re: Compare between clojure and Java

2016-01-05 Thread gvim

On 05/01/2016 13:44, Josh Kamau wrote:

Here is an extremely simple example:

Problem: add a list of numbers

java: You put something like this in a class in a method

int[] numbers = {1,2,3,4,5,6,7,7,8,4,3} ;

int sum = 0 ;
for(int i = 0; i < sum.length; i++) {
 sum = sum + i;
}

return sum;


clojure: You put this in a clojure namespace

(def numbers [1 2 3 4 54 56 6])

;;to get the sum
(reduce + numbers)


You get the idea ;)

Josh



Even more painful is:

public class Klass {
public HashMap data = new HashMap();
data.put("key1", "value1");
data.put("key2", "value2");
data.put("key3", "value3");
data.put("key4", "value4");
}

 versus:

(def my-map {:key1 "value1" :key2 "value2" :key3 "value3" :key4 "value4"})

The complexity is compounded in Java if you want mixed-type values or 
arbitrary nesting. In Clojure it is pure simplicity:


(def my-map {:key1 "value1" :key2 55 :key3 [:m1 {:k1 "val1" :k2 67} :m2 
{:k1 "val1" :k2 [1 2 3 4]}] :key4 #{2 4 "name" :id}})


(get-in my-map [:key3 3 :k2 3])  ; => 4

gvim




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


[ANN] Clojure/west 2016 in Seattle!

2016-01-05 Thread Alex Miller
Clojure/west 2016 will be held Apr 15-16 in Seattle at the Seattle Marriott
Waterfront.
You can find more info here: http://clojurewest.org

The CFP is open now and we encourage everyone to submit talks about
Clojure, ClojureScript, or other Clojure-related topics. You can find more
information about the process at: http://clojurewest.org/cfp

In particular we want to emphasize that we seek a diversity of voices at
the conference and we are happy to receive submissions and work with new as
well as experienced speakers. We are happy to review abstracts prior to
submission and suggest improvements. We can also connect speakers with
mentors or provide other assistance. Send any questions to
eve...@cognitect.com.

As a potential attendee, you can also add requested talk suggestions to the
list at:
https://github.com/clojurewest/clojurewest2016/wiki/Suggested-Topics

This is a new experiment to let the community suggest topics for talks
they'd like to see and for speakers to have a place to go for ideas.

Sponsorship opportunities are also available - this is a great way to reach
400-500 Clojure developers for hiring or other outreach. You can find more
information about sponsoring at http://clojurewest.org/sponsorship or
contact eve...@cognitect.com.

Hope to see you all there!
Alex

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


Re: Compare between clojure and Java

2016-01-05 Thread Thomas
While these examples are good (there is also a good one in Suart Halloways 
book for instance) I think it would be better to look at the difference for 
a whole project. There is for instance a talk from Nokia Bristol a few 
years ago (Now MixRadio)  where they went from 44K LOC to 4K LOC with more 
functionality. There are a few more examples around on the web I think.

Thomas

On Tuesday, 5 January 2016 13:27:10 UTC, Thomas Saillard wrote:
>
> Dear,
>  
> In order to good understand the powerful of Clojure,
> I have heard that compare to a code in java you need only few lines in 
> clojure.
> Is that true ?
> If it is the case, have you a sample of the 2 codes ?
> I appreciate your help.
> My Kind regards,
> Thomas
>

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


Re: Compare between clojure and Java

2016-01-05 Thread Nando Breiter
A proper comparison extends beyond a lines of code comparison. Clojure is a
functional language, while Java is object oriented. If you haven't seen it,
an excellent talk comparing the 2 approaches can be found here:
https://www.youtube.com/watch?v=Tb823aqgX_0



Aria Media Sagl
Via Rompada 40
6987 Caslano
Switzerland

+41 (0)91 600 9601
+41 (0)76 303 4477 cell
skype: ariamedia

On Tue, Jan 5, 2016 at 3:51 PM, Thomas  wrote:

> While these examples are good (there is also a good one in Suart Halloways
> book for instance) I think it would be better to look at the difference for
> a whole project. There is for instance a talk from Nokia Bristol a few
> years ago (Now MixRadio)  where they went from 44K LOC to 4K LOC with more
> functionality. There are a few more examples around on the web I think.
>
> Thomas
>
>
> On Tuesday, 5 January 2016 13:27:10 UTC, Thomas Saillard wrote:
>>
>> Dear,
>>
>> In order to good understand the powerful of Clojure,
>> I have heard that compare to a code in java you need only few lines in
>> clojure.
>> Is that true ?
>> If it is the case, have you a sample of the 2 codes ?
>> I appreciate your help.
>> My Kind regards,
>> Thomas
>>
> --
> 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.


Re: Compare between clojure and Java

2016-01-05 Thread Josh Kamau
Here is an extremely simple example:

Problem: add a list of numbers

java: You put something like this in a class in a method

int[] numbers = {1,2,3,4,5,6,7,7,8,4,3} ;

int sum = 0 ;
for(int i = 0; i < sum.length; i++) {
sum = sum + i;
}

return sum;


clojure: You put this in a clojure namespace

(def numbers [1 2 3 4 54 56 6])

;;to get the sum
(reduce + numbers)


You get the idea ;)

Josh


On Tue, Jan 5, 2016 at 4:19 PM, Thomas Saillard 
wrote:

> Dear,
>
> In order to good understand the powerful of Clojure,
> I have heard that compare to a code in java you need only few lines in
> clojure.
> Is that true ?
> If it is the case, have you a sample of the 2 codes ?
> I appreciate your help.
> My Kind regards,
> Thomas
>
> --
> 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.


Re: Possible bug in AOT-compiled Clojure when ns-unmap is used

2016-01-05 Thread 'wparke...@yahoo.com' via Clojure
I have logged an issue at http://dev.clojure.org/jira/browse/CLJ-1874  

Thank you all for the responses.

On Wednesday, December 30, 2015 at 12:02:35 PM UTC-6, Nicola Mometto wrote:
>
> While it's true that AOT has many issues, it's getting better release 
> after release and this is definitely a bug. 
> I don't understand why you wouldn't expect this to work, you *should*. 
>
> OP: can you open a ticket for this bug? I'd love to have a look at this 
> and try to fix it. 
>
> > On 29 Dec 2015, at 17:28, Stuart Sierra  > wrote: 
> > 
> > AOT-compilation breaks almost any code that tries to redefine Vars. I 
> wouldn't expect this to work. 
> > —S 
> > 
> > 
> > On Monday, December 28, 2015, wparker30 wrote: 
> > I have found what appears to be a bug in AOT-compiled Clojure when 
> ns-unmap is used.  I have the following reduced case: 
> > 
> > (ns unmap-test.core) 
> > 
> > (def a :test-1) 
> > 
> > (ns-unmap 'unmap-test.core 'a) 
> > 
> > (def a :test-2) 
> > 
> > It turns out that a is not resolvable when this namespace is loaded. 
>  When I looked at the compiled bytecode, 
> > it appears that the following operations occur: 
> > 
> > 1. A call to RT.var withe 'unmap-test.core and 'a returns a Var, which 
> is bound to a constant. 
> >   This var is added to the namespaces's mapping during this call. 
> > 2. Same as 1. 
> > 3. The var from 1 is bound to :test-1. 
> > 4. ns-unmap is called. 
> > 5. The var from 2 is bound to :test-2. 
> > 
> > Disclaimer: This is the first time I have had occasion to look directly 
> at bytecode and I could be missing something. 
> > 
> > The basic problem here is that the var is accessible from the load 
> method, but when step 5 executes the var is no longer 
> > accessible from the namespace mappings.  Thus, the root of the Var is 
> set to :test-2, but that Var is not mapped from the namespace. 
> > This works when there is no AOT compilation, as well as when I use 
> > 
> > (ns unmap-test.core) 
> > 
> > (def a :test-1) 
> > 
> > (ns-unmap 'unmap-test.core 'a) 
> > 
> > (intern 'unmap-test.core 'a :test-2) 
> > 
> > I realize that creating defs, unmapping them, and then recreating them 
> is generally poor practice in Clojure. 
> > We have an odd case in that we need to have an interface and a Var of 
> the same name in the same namespace.  Simply 
> > doing definterface and then def causes a compilation failure: 
> > 
> > user=> (definterface abc) 
> > user.abc 
> > user=> (def abc 1) 
> > CompilerException java.lang.RuntimeException: Expecting var, but abc is 
> mapped to interface user.abc, 
> compiling:(/private/var/folders/3m/tvc28b5d7p50v5_8q5ntj0pmflbdh9/T/form-init4734176956271823921.clj:1:1)
>  
>
> > 
> > Without going into too much detail, this is basically a hack to allow us 
> to refactor our internal framework code 
> > without immediately changing a very large amount of downstream consumer 
> code.  We get rid of the usage of the interface during macroexpansion, 
> > but it still needs to exist on the classpath so it can be imported by 
> downstream namespaces.   
> > There are a number of other ways to accomplish this, so it isn't a 
> particularly big problem for us, but I thought the issue was worth raising. 
> > This was just the first thing I tried and I was surprised when it didn't 
> work. 
> > 
> > Note that I used the 1.8.0 RC4 version of Clojure in my sample project, 
> but I had the same behavior on 1.7.0. 
> > 
> > Relevant links: 
> > 
> > 1. Bytecode for the load method of the init class: 
> https://gist.github.com/WilliamParker/d8ef4c0555a30135f35a 
> > 2. Bytecode for the init0 method: 
> https://gist.github.com/WilliamParker/dc606ad086670915efd9 
> > 3. Decompiled Java code for the init class.  Note that this does not 
> completely line up with the bytecode as far as I can tell, 
> > but it is a quicker way to get a general idea of what is happening than 
> the bytecode. 
> > https://gist.github.com/WilliamParker/4cc47939f613d4595d94 
> > 4. A simple project containing the code above: 
> https://github.com/WilliamParker/unmap-test 
> > Note that if you try it without AOT compilation the target folder with 
> any previously compiled classes should be removed. 
> > 
> > I may or may not be able to respond to any replies before next week; I 
> apologize for any delayed responses. 
> > 
> > -- 
> > 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 unsubscribe from this group and stop receiving emails from it, send 

Re: Possible bug in AOT-compiled Clojure when ns-unmap is used

2016-01-05 Thread Nicola Mometto
Thanks for that, I've attached a possible fix to the ticket.

> On 5 Jan 2016, at 15:40, 'wparke...@yahoo.com' via Clojure 
>  wrote:
> 
> I have logged an issue at http://dev.clojure.org/jira/browse/CLJ-1874  
> 
> Thank you all for the responses.
> 
> On Wednesday, December 30, 2015 at 12:02:35 PM UTC-6, Nicola Mometto wrote:
> While it's true that AOT has many issues, it's getting better release after 
> release and this is definitely a bug. 
> I don't understand why you wouldn't expect this to work, you *should*. 
> 
> OP: can you open a ticket for this bug? I'd love to have a look at this and 
> try to fix it. 
> 
> > On 29 Dec 2015, at 17:28, Stuart Sierra  wrote: 
> > 
> > AOT-compilation breaks almost any code that tries to redefine Vars. I 
> > wouldn't expect this to work. 
> > —S 
> > 
> > 
> > On Monday, December 28, 2015, wparker30 wrote: 
> > I have found what appears to be a bug in AOT-compiled Clojure when ns-unmap 
> > is used.  I have the following reduced case: 
> > 
> > (ns unmap-test.core) 
> > 
> > (def a :test-1) 
> > 
> > (ns-unmap 'unmap-test.core 'a) 
> > 
> > (def a :test-2) 
> > 
> > It turns out that a is not resolvable when this namespace is loaded.  When 
> > I looked at the compiled bytecode, 
> > it appears that the following operations occur: 
> > 
> > 1. A call to RT.var withe 'unmap-test.core and 'a returns a Var, which is 
> > bound to a constant. 
> >   This var is added to the namespaces's mapping during this call. 
> > 2. Same as 1. 
> > 3. The var from 1 is bound to :test-1. 
> > 4. ns-unmap is called. 
> > 5. The var from 2 is bound to :test-2. 
> > 
> > Disclaimer: This is the first time I have had occasion to look directly at 
> > bytecode and I could be missing something. 
> > 
> > The basic problem here is that the var is accessible from the load method, 
> > but when step 5 executes the var is no longer 
> > accessible from the namespace mappings.  Thus, the root of the Var is set 
> > to :test-2, but that Var is not mapped from the namespace. 
> > This works when there is no AOT compilation, as well as when I use 
> > 
> > (ns unmap-test.core) 
> > 
> > (def a :test-1) 
> > 
> > (ns-unmap 'unmap-test.core 'a) 
> > 
> > (intern 'unmap-test.core 'a :test-2) 
> > 
> > I realize that creating defs, unmapping them, and then recreating them is 
> > generally poor practice in Clojure. 
> > We have an odd case in that we need to have an interface and a Var of the 
> > same name in the same namespace.  Simply 
> > doing definterface and then def causes a compilation failure: 
> > 
> > user=> (definterface abc) 
> > user.abc 
> > user=> (def abc 1) 
> > CompilerException java.lang.RuntimeException: Expecting var, but abc is 
> > mapped to interface user.abc, 
> > compiling:(/private/var/folders/3m/tvc28b5d7p50v5_8q5ntj0pmflbdh9/T/form-init4734176956271823921.clj:1:1)
> >  
> > 
> > Without going into too much detail, this is basically a hack to allow us to 
> > refactor our internal framework code 
> > without immediately changing a very large amount of downstream consumer 
> > code.  We get rid of the usage of the interface during macroexpansion, 
> > but it still needs to exist on the classpath so it can be imported by 
> > downstream namespaces.   
> > There are a number of other ways to accomplish this, so it isn't a 
> > particularly big problem for us, but I thought the issue was worth raising. 
> > This was just the first thing I tried and I was surprised when it didn't 
> > work. 
> > 
> > Note that I used the 1.8.0 RC4 version of Clojure in my sample project, but 
> > I had the same behavior on 1.7.0. 
> > 
> > Relevant links: 
> > 
> > 1. Bytecode for the load method of the init class: 
> > https://gist.github.com/WilliamParker/d8ef4c0555a30135f35a 
> > 2. Bytecode for the init0 method: 
> > https://gist.github.com/WilliamParker/dc606ad086670915efd9 
> > 3. Decompiled Java code for the init class.  Note that this does not 
> > completely line up with the bytecode as far as I can tell, 
> > but it is a quicker way to get a general idea of what is happening than the 
> > bytecode. 
> > https://gist.github.com/WilliamParker/4cc47939f613d4595d94 
> > 4. A simple project containing the code above: 
> > https://github.com/WilliamParker/unmap-test 
> > Note that if you try it without AOT compilation the target folder with any 
> > previously compiled classes should be removed. 
> > 
> > I may or may not be able to respond to any replies before next week; I 
> > apologize for any delayed responses. 
> > 
> > -- 
> > 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 
> > 

Pattern for service with multiple clients using two-way channels?

2016-01-05 Thread Vic Putz
I love the idea of core.async channels as generic inboxes for "in-program 
microservices" for lack of a better term.  They're a great decoupling 
mechanism.

But I get a little confused when you get beyond a producer-consumer model.  
A service with an inbox (consumer) works well for multiple clients 
(producers) because they can all just dump data into the same inbox.  But 
it gets a little trickier if you want any data back (toy example: a jukebox 
microservice with an input channel: drop the song name in as a string and 
it starts playing, and doesn't care if A, B, or C dropped the song name in, 
but if A wants a list of available songs you need a return channel and the 
jukebox can't just drop A's list of songs in a single outbox.

Either it feels like you need separate return channels for each client 
(which complects transport with processing, but would let each client 
pretend they had a private connection) or you have to use core.async 
publish-subscribe, maybe pulling "sender" out of the topic for the return 
address and have clients subscribe to the service's output channel based on 
their own identifier, but that forces messages to carry extra information 
about routing... which may be fine.

Is there an established pattern or mechanism for this, or is pub/sub 
probably the best way to go?

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


[ANN] org.clojure/tools.namespace "0.3.0-alpha3"

2016-01-05 Thread Stuart Sierra
tools.namespace
https://github.com/clojure/tools.namespace

Development tools for managing namespaces in Clojure. Parse ns declarations 
from source files, extract their dependencies, build a graph of namespace 
dependencies within a project, update that graph as files change, and 
reload files in the correct order.

Release 0.3.0-alpha3

Leiningen dependency [org.clojure/tools.namespace "0.3.0-alpha3"]

This is a development release. Changes:

* Ignore `:require-macros` and `:use-macros` when parsing namespace 
dependencies. This is a change in behavior from previous 0.3 alphas and is 
a more robust fix for [TNS-38]. tools.namespace currently only models one 
dependency graph at a time, so it treats Clojure and ClojureScript as 
separate worlds and will not attempt to analyze dependency relationships 
which cross that boundary.

* Fix [TNS-40]: do not catch exceptions in `c.t.n.file`. Instead, catch and 
ignore only syntax exceptions (identified by `ex-data` from 
[tools.reader]). This is a change in behavior from 0.3.0-alpha2 and 0.2. It 
should have minimal impact on users but make some errors (such as an 
incompatible version of tools.reader) more obvious.

* Known bugs not yet fixed: [TNS-42] When the same namespace is defined in 
both `.clj` and `.cljc` files, dependencies may be read from either, when 
it should prefer the `.clj` file.

[TNS-38]: http://dev.clojure.org/jira/browse/TNS-38
[TNS-40]: http://dev.clojure.org/jira/browse/TNS-40
[TNS-42]: http://dev.clojure.org/jira/browse/TNS-42

Full change log:
https://github.com/clojure/tools.namespace/blob/master/CHANGES.md

This is a Clojure-contrib project:
http://dev.clojure.org/display/doc/Clojure+Contrib



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


Re: Compare between clojure and Java

2016-01-05 Thread gvim

On 05/01/2016 13:44, Josh Kamau wrote:

Here is an extremely simple example:

Problem: add a list of numbers

java: You put something like this in a class in a method

int[] numbers = {1,2,3,4,5,6,7,7,8,4,3} ;

int sum = 0 ;
for(int i = 0; i < sum.length; i++) {
 sum = sum + i;
}

return sum;


clojure: You put this in a clojure namespace

(def numbers [1 2 3 4 54 56 6])

;;to get the sum
(reduce + numbers)


You get the idea ;)

Josh




Or simply:

(reduce + [1 2 3 4 54 56 6])

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


Re: [Clojurescript] .getElementById returns NULL

2016-01-05 Thread Nathan Smutz
Thanks Francis, that did it.

Rookie mistake, that.
I wonder if there's ever enough page content to make it worth just delaying 
the DOM hooks.   

On Sunday, January 3, 2016 at 7:49:39 PM UTC-8, Francis Avila wrote:
>
> Your problem is unrelated to clojurescript.
>
> Your script runs before the body is loaded, so the test-content element 
> doesn't exist yet.
>
> Either load your script at the end of the body, or wrap your code in a 
> document.onload event handler.
>
>

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


Compare between clojure and Java

2016-01-05 Thread Thomas Saillard
Dear,
 
In order to good understand the powerful of Clojure,
I have heard that compare to a code in java you need only few lines in 
clojure.
Is that true ?
If it is the case, have you a sample of the 2 codes ?
I appreciate your help.
My Kind regards,
Thomas

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