Re: Vars as global thread-locals?

2017-02-25 Thread Didier
Re-reading your reply, sounds like I might have explained what you already 
know. So to better answer your question:

Dynamic scoping and Java ThreadLocals gives you equal functionality, so I'd 
use them equally. This is because Clojure supports thread bound dynamic 
scope.

On Wednesday, 8 February 2017 14:39:59 UTC-8, Ernesto Garcia wrote:
>
> Hi Alex, thanks for your thorough response.
>
> It seems to me that Clojure vars are just not intended to be used as 
> thread-locals in general. They happen to use thread-local storage in order 
> to implement dynamic scoping, which is the original intent.
>
> That is why vars are either global (interned in a namespace), or confined 
> to a dynamic scope (via with-local-vars).
>
> If one needs thread-local storage, you use a Java ThreadLocal directly.
>

-- 
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: Vars as global thread-locals?

2017-02-25 Thread Didier
"If one needs thread-local storage, you use a Java ThreadLocal directly."

No, you just use a dynamic Var for that or with-local-vars.

Normally, in Clojure, values are bound to symbols. This means that a symbol 
is mapped to a value. In general, you can not change this mapping once it 
is set. This is true in local contexts, such as when using (let) or with 
function arguments.

In cases where you need to change the mapping, you'll need to have an extra 
layer of indirection, since you can not actually change it. To do this, 
Clojure gives you a few constructs such as Vars, Refs, Agents and Atoms.

A Var is a mapping from thread to value, with support for an optional root 
value (like a default value if no value for the current thread exists on 
the Var). So instead of doing Symbol -> Value, you will do Symbol -> 
Var(CurrentThread) -> Value.

By default, Vars just have a root, and you can not dynamically add new 
thread to value mappings to them unless they are declared dynamic.

Now, when you do "def" or what is called "intern", you are creating a new 
mapping from Symbol to Var on the current Namespace. This can be thought of 
as the global context. When you use a symbol, Clojure will first look for 
it inside local contexts, and if it does not find it there, it will look 
for it in the current namespace. If it is a fully qualified symbol, it'll 
go looking for it directly inside the namespace you qualified. What this 
means is that, on a Namespace, you can not map Symbols to Values, you can 
only map Symbols to Vars. In local contexts, you can map symbols to 
whatever you want, but not in the global context.

The reason Clojure always forces you to map symbols to vars at the 
namespace level are unknown to me, but that's what it does.

All that to say, if you want a per-thread value, go ahead and use a dynamic 
Var. You can choose to make it global, by using def, or to make it local, 
by creating a local Var using (with-local-vars). No need to use Java's 
ThreadLocals directly.

Keep in mind that if you have sub-threads, they won't always inherit their 
parent's bindings. They only do inside (future) and if using (bound-fn).

On Wednesday, 8 February 2017 14:39:59 UTC-8, Ernesto Garcia wrote:
>
> Hi Alex, thanks for your thorough response.
>
> It seems to me that Clojure vars are just not intended to be used as 
> thread-locals in general. They happen to use thread-local storage in order 
> to implement dynamic scoping, which is the original intent.
>
> That is why vars are either global (interned in a namespace), or confined 
> to a dynamic scope (via with-local-vars).
>
> If one needs thread-local storage, you use a Java ThreadLocal directly.
>

-- 
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: [ANN] Odin 0.2.0 - Query DSL for Clojure

2017-02-25 Thread Didier
Interesting, thanks.

FYI: I do not see that question in the QA of the readme. I see Datalog and 
core.logic comparison, but not specter.

On Friday, 24 February 2017 17:11:16 UTC-8, tbc++ wrote:
>
> It's in the QA in the readme, but specter only queries a single path 
> through the data. Odin supports relations, joins, recursive rules, tabling, 
> etc. 
>
> Currently Specter will probably perform a bit better, but I hope to close 
> that gap in the future.
>
>
> Timothy
>
> On Fri, Feb 24, 2017 at 5:10 PM Didier > 
> wrote:
>
>> How does this compare to Specter?
>>
>>
>> On Thursday, 23 February 2017 13:34:16 UTC-8, Alan Thompson wrote:
>>
>>> Just came across this - it looks very cool!
>>> Alan
>>>
>> On Sat, Dec 10, 2016 at 7:14 AM, Timothy Baldridge  
>>> wrote:
>>>
>> I just released the first official version of Odin (
 https://github.com/halgari/odin). Odin is a declarative, extensible 
 query DSL for Clojure that leverages transducers to provide a high amount 
 of generality while still maintaining acceptable performance. 

 One of the biggest features of Odin is its ability to rapidly index and 
 query "normal" Clojure data structures. Here is a quick example of this 
 feature in practice: 

 (let [orders [{:customer/name "Sam"
:customer/id   3411}
   {:customer/id 3411
:order/items {1212 3}}
   {:customer/id 3411
:order/items {2232 2 4242 3}}
   {:item/id1212
:item/price 40.0}
   {:item/id2232
:item/price 100}
   {:item/id4242
:item/price 1.99}]]
   (->> (o/for-query
  (o/and
(d/query orders ?customer :customer/name "Sam")
(d/query orders ?customer :customer/id ?id)
(d/query orders ?order :customer/id ?id)
(d/query-in orders ?order [:order/items ?item-id] ?qty)
(d/query orders ?item :item/id ?item-id)
(d/query orders ?item :item/price ?price))
  (* ?qty ?price))
(reduce + 0)))

 ;; => 325.97


 In this example we are given a vector of maps, we are then finding a 
 customer by name,

 then walking a path through the data to find all the items that customer 
 ordered, the

 total price is then calculated via the normal multiply and sum. 


 There are several other features supported by Odin, including 
 transformation of data

 (based on a query), tabling, Datomic support, and much more. 


 I also did a video series on the development process of Odin if anyone is 
 interested: 
 (https://www.youtube.com/watch?v=JyKySmcTR4g)

 -- 
 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 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.
>>
> -- 
> “One of the main causes of the fall of the Roman Empire was that–lacking 
> zero–they had no way to indicate successful termination of their C 
> programs.”
> (Robert Firth) 
>

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

Re: FYI: Eclipse Aether moved to Apache Maven

2017-02-25 Thread Andrea Richiardi
Hey Colin, I agree totally, I have a patch kind of 
ready: https://github.com/cemerick/pomegranate/pull/80 :)

On Saturday, February 25, 2017 at 3:02:57 PM UTC-8, Colin Fleming wrote:
>
> Hi all,
>
> I just saw a notice about this on the Aether mailing list today, and it 
> potentially affects some of us building tooling (especially 
> Leiningen/boot/pomegranate etc). Aether has been developed under the 
> Eclipse umbrella until recently, but as far as I could tell had been almost 
> totally abandoned there. It's just been switched over to being managed 
> under Apache Maven. Its new site is at https://maven.apache.org/resolver, 
> and the mailing lists are us...@maven.apache.org  and 
> d...@maven.apache.org . I hope this will lead to it being 
> more actively maintained.
>
> Cheers,
> Colin
>
>
>

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


FYI: Eclipse Aether moved to Apache Maven

2017-02-25 Thread Colin Fleming
Hi all,

I just saw a notice about this on the Aether mailing list today, and it
potentially affects some of us building tooling (especially
Leiningen/boot/pomegranate etc). Aether has been developed under the
Eclipse umbrella until recently, but as far as I could tell had been almost
totally abandoned there. It's just been switched over to being managed
under Apache Maven. Its new site is at https://maven.apache.org/resolver,
and the mailing lists are us...@maven.apache.org and d...@maven.apache.org.
I hope this will lead to it being more actively maintained.

Cheers,
Colin

-- 
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: Prgram uses a lot of swap

2017-02-25 Thread Cecil Westerhof
2017-02-24 15:07 GMT+01:00 Timothy Baldridge :

> What are the JVM memory settings set at? And how much physical memory does
> the box have?
>

​My system has 16 GB of memory.

I use ‘lein  run’ and this results in the following process:

java-Xbootclasspath/a:/home/cecil/.lein/self-installs/leiningen-2.6.1-standalone.jar-Dfile.encoding=UTF-8-Dmaven.wagon.http.ssl.easy=false-Dmaven.wagon.rto=1-XX:+TieredCompilation-XX:TieredStopAtLevel=1-Dleiningen.original.pwd=/home/cecil/Clojure/Quotes-Dleiningen.script=/home/cecil/bin/lein-classpath.:/home/cecil/scala:/var/lib/h2/jars/h2-current.jar:/home/cecil/Java/jars/sqlite-jdbc.jar:/home/cecil/Java/jars/javax.mail.jar:/home/cecil/Java/qtjambi-linux64-4.7.4-beta-4/qtjambi-4.7.4-beta-4.jar:/home/cecil/Java/qtjambi-linux64-4.7.4-beta-4/qtjambi-examples-4.7.4-beta-4.jar:/home/cecil/Java/qtjambi-linux64-4.7.4-beta-4/qtjambi-native-linux64-gcc-4.7.4-beta-4:/home/cecil/Java/ghost4j/ghost4j-0.5.0.jar:/home/cecil/.lein/self-installs/leiningen-2.6.1-standalone.jarclojure.main-mleiningen.core.mainrun

The program itself is:

java-classpath/home/cecil/Clojure/Quotes/test:/home/cecil/Clojure/Quotes/src:/home/cecil/Clojure/Quotes/dev-resources:/home/cecil/Clojure/Quotes/resources:/home/cecil/Clojure/Quotes/target/classes:/home/cecil/.m2/repository/org/clojure/clojure/1.8.0/clojure-1.8.0.jar:/home/cecil/.m2/repository/com/miglayout/miglayout/3.7.4/miglayout-3.7.4.jar:/home/cecil/.m2/repository/org/clojure/tools.nrepl/0.2.12/tools.nrepl-0.2.12.jar:/home/cecil/.m2/repository/clojure-complete/clojure-complete/0.2.4/clojure-complete-0.2.4.jar:/home/cecil/.m2/repository/org/clojure/java.jdbc/0.5.8/java.jdbc-0.5.8.jar:/home/cecil/.m2/repository/org/clojure/math.numeric-tower/0.0.4/math.numeric-tower-0.0.4.jar:/home/cecil/.m2/repository/com/fifesoft/rsyntaxtextarea/2.5.6/rsyntaxtextarea-2.5.6.jar:/home/cecil/.m2/repository/org/swinglabs/swingx/swingx-autocomplete/1.6.3/swingx-autocomplete-1.6.3.jar:/home/cecil/.m2/repository/j18n/j18n/1.0.2/j18n-1.0.2.jar:/home/cecil/.m2/repository/clj-time/clj-time/0.12.0/clj-time-0.12.0.jar:/home/cecil/.m2/repository/org/swinglabs/swingx/swingx-plaf/1.6.3/swingx-plaf-1.6.3.jar:/home/cecil/.m2/repository/org/swinglabs/swingx/swingx-painters/1.6.3/swingx-painters-1.6.3.jar:/home/cecil/.m2/repository/com/jgoodies/forms/1.2.1/forms-1.2.1.jar:/home/cecil/.m2/repository/joda-time/joda-time/2.9.3/joda-time-2.9.3.jar:/home/cecil/.m2/repository/com/h2database/h2/1.3.176/h2-1.3.176.jar:/home/cecil/.m2/repository/seesaw/seesaw/1.4.5/seesaw-1.4.5.jar:/home/cecil/.m2/repository/org/swinglabs/swingx/swingx-common/1.6.3/swingx-common-1.6.3.jar:/home/cecil/.m2/repository/org/swinglabs/swingx/swingx-core/1.6.3/swingx-core-1.6.3.jar:/home/cecil/.m2/repository/instaparse/instaparse/1.4.2/instaparse-1.4.2.jar:/home/cecil/.m2/repository/org/swinglabs/swingx/swingx-action/1.6.3/swingx-action-1.6.3.jar:/home/cecil/.m2/repository/yesql/yesql/0.5.3/yesql-0.5.3.jar-Dfile.encoding=UTF-8-Xmx4096M-Dclojure.compile.path=/home/cecil/Clojure/Quotes/target/classes-Dquotes.version=0.0.1-Dclojure.debug=falseclojure.main-i/tmp/form-init417092364626579473.clj

​So maximum memory is set to 4 GB. That could probably be a lot less.​
Where can I change that?
And can I set the maximum memory for lein?


-- 
Cecil Westerhof

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