[ANN] oolong 0.4.0 - the cljs support release

2016-12-09 Thread James Laver
Hi all,

We added cljs support to oolong and tidied it up a little bit. We now 
require clojure 1.7 for cljc support.

https://github.com/irresponsible/oolong/

At this point oolong is considered relatively stable and is transitioning 
to maintenance mode, so we're still happy to take patches, but we won't be 
actively developing it.

Happy hacking!

James


-- 
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] An exploration of Hash Array Mapped Tries

2016-12-09 Thread Colin Fleming
Hi Ambrose,

This looks very interesting, and I look forward to investigating it further
when I have a moment.

Once comment on the defrecords generated at runtime based on small keysets
- I'd be very careful with this sort of optimisation, and it needs much
more than micro-benchmarks to establish whether it's really a win or not. A
recent similar change that was proposed for Clojure was Zach Tellman's
unrolled small collections (see CLJ-1517
, in particular see Rich's
comment here
).
Essentially, the JVM optimises call sites speculatively. Per call site, if
you only see a single implementation of the interface you're calling, the
site is monomorphic and very highly optimised. If two implementations are
seen, the site is bimorphic, and optimised but not as highly. If more than
two implementations are seen, the call site is considered megamorphic and
is optimised poorly. Additionally, the optimisations that are applied can
depend on the order in which the different implementations are seen, which
can produce extremely unpredictable performance.

There's a very interesting issue
 on the Google Guava tracker
with tons of really interesting detail by people who know way more about
this than I do. It's highly recommended. The tl;dr is that your benchmarks
must mix collection types to measure benefit, and that those benchmarks are
extremely difficult to relate to real-world use.

Since reading all that, I've often wondered how much Clojure's
PersistentArrayMap might affect performance since it will probably cause
many call sites to be bimorphic rather than monomorphic. I could imagine it
being worthwhile to have a flag which only ever uses PersistentHashMap
instead for people who really understand their workload, but I have never
had time to investigate it more.

Cheers,
Colin

On 6 December 2016 at 22:16, Ambrose Bonnaire-Sergeant <
abonnaireserge...@gmail.com> wrote:

> Hi,
>
> I've been having a ton of fun this semester learning about
> Hash Array Mapped Tries (like PersistentHashMap).
>
> Link
>
> I have written a visual tutorial for HAMT's, as well
> as a reference implementation in Clojure that supports
> trie visualisations with Rhizome.
>
> There's also a little prototype+writeup of an idea I had about
> generating defrecords at runtime based on the frequency
> of certain keysets at runtime.
>
> Enjoy!
>
> Ambrose
>
> --
> 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.


finding clojure functions from the mangled names

2016-12-09 Thread Brian Craft
Trying to profile some code, and the stack traces look like

clojure.something0
  clojure.something1
   clojure.something2
 
  clojure.something100
 foo$fn_1000$fn_1002$fn_10003.invoke()


How can I figure out what that last function is? I can access the symbol 
from the repl, but no idea how to connect it to my code.

-- 
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: finding clojure functions from the mangled names

2016-12-09 Thread Alex Engelberg
If you're seeing "fn_123", it's probably coming from an anonymous function.
Giving those functions a name with the (fn my-name [] ...) syntax will make
the stack trace a little easier to decipher:

user=> ((fn [] (/ 1 0)))

ArithmeticException Divide by zero  clojure.lang.Numbers.divide
(Numbers.java:158)

user=> (pst)

ArithmeticException Divide by zero
clojure.lang.Numbers.divide (Numbers.java:158)
clojure.lang.Numbers.divide (Numbers.java:3808)
user/eval20851/fn--20852 (form-init8836862334241327650.clj:1)
​...​

nil
user=> ((fn my-fn-with-a-name [] (/ 1 0))

ArithmeticException Divide by zero  clojure.lang.Numbers.divide
(Numbers.java:158)
user=> (pst)
ArithmeticException Divide by zero
clojure.lang.Numbers.divide (Numbers.java:158)
clojure.lang.Numbers.divide (Numbers.java:3808)
user/eval20857/my-fn-with-a-name--20858 (form-init8836862334241327650.clj:1)
​...​

nil

On Fri, Dec 9, 2016 at 3:00 PM, Brian Craft  wrote:

> Trying to profile some code, and the stack traces look like
>
> clojure.something0
>   clojure.something1
>clojure.something2
>  
>   clojure.something100
>  foo$fn_1000$fn_1002$fn_10003.invoke()
>
>
> How can I figure out what that last function is? I can access the symbol
> from the repl, but no idea how to connect it to my code.
>
> --
> 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: finding clojure functions from the mangled names

2016-12-09 Thread Brian Craft
Yes, but not very practical: since I don't know which one to change, this 
would be a huge rewrite of code to eliminate #() and (fn []).


On Friday, December 9, 2016 at 3:16:06 PM UTC-8, Alex Engelberg wrote:
>
> If you're seeing "fn_123", it's probably coming from an anonymous 
> function. Giving those functions a name with the (fn my-name [] ...) syntax 
> will make the stack trace a little easier to decipher:
>
> user=> ((fn [] (/ 1 0)))
>
> ArithmeticException Divide by zero  clojure.lang.Numbers.divide 
> (Numbers.java:158)
>
> user=> (pst)
>
> ArithmeticException Divide by zero
> clojure.lang.Numbers.divide (Numbers.java:158)
> clojure.lang.Numbers.divide (Numbers.java:3808)
> user/eval20851/fn--20852 (form-init8836862334241327650.clj:1)
> ​...​
>
> nil
> user=> ((fn my-fn-with-a-name [] (/ 1 0))
>
> ArithmeticException Divide by zero  clojure.lang.Numbers.divide 
> (Numbers.java:158)
> user=> (pst)
> ArithmeticException Divide by zero
> clojure.lang.Numbers.divide (Numbers.java:158)
> clojure.lang.Numbers.divide (Numbers.java:3808)
> user/eval20857/my-fn-with-a-name--20858 
> (form-init8836862334241327650.clj:1)
> ​...​
>
> nil
>
> On Fri, Dec 9, 2016 at 3:00 PM, Brian Craft  > wrote:
>
>> Trying to profile some code, and the stack traces look like
>>
>> clojure.something0
>>   clojure.something1
>>clojure.something2
>>  
>>   clojure.something100
>>  foo$fn_1000$fn_1002$fn_10003.invoke()
>>
>>
>> How can I figure out what that last function is? I can access the symbol 
>> from the repl, but no idea how to connect it to my code.
>>
>> -- 
>> 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: finding clojure functions from the mangled names

2016-12-09 Thread Brian Craft
Well, a truly painful way is to dump the const__ fields on the class, 
which appear to be values in the closure, from which the function might be 
inferred.

Like

(. foo$fn__7840$fn__7846$fn__7847 const__0)
(. foo$fn__7840$fn__7846$fn__7847 const__1)
...




On Friday, December 9, 2016 at 3:25:24 PM UTC-8, Brian Craft wrote:
>
> Yes, but not very practical: since I don't know which one to change, this 
> would be a huge rewrite of code to eliminate #() and (fn []).
>
>
> On Friday, December 9, 2016 at 3:16:06 PM UTC-8, Alex Engelberg wrote:
>>
>> If you're seeing "fn_123", it's probably coming from an anonymous 
>> function. Giving those functions a name with the (fn my-name [] ...) syntax 
>> will make the stack trace a little easier to decipher:
>>
>> user=> ((fn [] (/ 1 0)))
>>
>> ArithmeticException Divide by zero  clojure.lang.Numbers.divide 
>> (Numbers.java:158)
>>
>> user=> (pst)
>>
>> ArithmeticException Divide by zero
>> clojure.lang.Numbers.divide (Numbers.java:158)
>> clojure.lang.Numbers.divide (Numbers.java:3808)
>> user/eval20851/fn--20852 (form-init8836862334241327650.clj:1)
>> ​...​
>>
>> nil
>> user=> ((fn my-fn-with-a-name [] (/ 1 0))
>>
>> ArithmeticException Divide by zero  clojure.lang.Numbers.divide 
>> (Numbers.java:158)
>> user=> (pst)
>> ArithmeticException Divide by zero
>> clojure.lang.Numbers.divide (Numbers.java:158)
>> clojure.lang.Numbers.divide (Numbers.java:3808)
>> user/eval20857/my-fn-with-a-name--20858 
>> (form-init8836862334241327650.clj:1)
>> ​...​
>>
>> nil
>>
>> On Fri, Dec 9, 2016 at 3:00 PM, Brian Craft  wrote:
>>
>>> Trying to profile some code, and the stack traces look like
>>>
>>> clojure.something0
>>>   clojure.something1
>>>clojure.something2
>>>  
>>>   clojure.something100
>>>  foo$fn_1000$fn_1002$fn_10003.invoke()
>>>
>>>
>>> How can I figure out what that last function is? I can access the symbol 
>>> from the repl, but no idea how to connect it to my code.
>>>
>>> -- 
>>> 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: finding clojure functions from the mangled names

2016-12-09 Thread Ghadi Shayban
The stacktrace should be pointing to the correct file & line number -- no 
need to reverse engineer the mangling.  If it's not for some reason, file a 
bug.  (It's helpful to eliminate nREPL / lein middleware in case something 
is transforming the printing of traces)
If you are missing a trace when the JVM JITs your code, run with -XX:-
*OmitStackTraceInFastThrow* 

On Friday, December 9, 2016 at 6:25:24 PM UTC-5, Brian Craft wrote:
>
> Yes, but not very practical: since I don't know which one to change, this 
> would be a huge rewrite of code to eliminate #() and (fn []).
>
>
> On Friday, December 9, 2016 at 3:16:06 PM UTC-8, Alex Engelberg wrote:
>>
>> If you're seeing "fn_123", it's probably coming from an anonymous 
>> function. Giving those functions a name with the (fn my-name [] ...) syntax 
>> will make the stack trace a little easier to decipher:
>>
>> user=> ((fn [] (/ 1 0)))
>>
>> ArithmeticException Divide by zero  clojure.lang.Numbers.divide 
>> (Numbers.java:158)
>>
>> user=> (pst)
>>
>> ArithmeticException Divide by zero
>> clojure.lang.Numbers.divide (Numbers.java:158)
>> clojure.lang.Numbers.divide (Numbers.java:3808)
>> user/eval20851/fn--20852 (form-init8836862334241327650.clj:1)
>> ​...​
>>
>> nil
>> user=> ((fn my-fn-with-a-name [] (/ 1 0))
>>
>> ArithmeticException Divide by zero  clojure.lang.Numbers.divide 
>> (Numbers.java:158)
>> user=> (pst)
>> ArithmeticException Divide by zero
>> clojure.lang.Numbers.divide (Numbers.java:158)
>> clojure.lang.Numbers.divide (Numbers.java:3808)
>> user/eval20857/my-fn-with-a-name--20858 
>> (form-init8836862334241327650.clj:1)
>> ​...​
>>
>> nil
>>
>> On Fri, Dec 9, 2016 at 3:00 PM, Brian Craft  wrote:
>>
>>> Trying to profile some code, and the stack traces look like
>>>
>>> clojure.something0
>>>   clojure.something1
>>>clojure.something2
>>>  
>>>   clojure.something100
>>>  foo$fn_1000$fn_1002$fn_10003.invoke()
>>>
>>>
>>> How can I figure out what that last function is? I can access the symbol 
>>> from the repl, but no idea how to connect it to my code.
>>>
>>> -- 
>>> 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: finding clojure functions from the mangled names

2016-12-09 Thread Brian Craft
This is in a profiler, not a repl: visualvm. If there's a way to make 
visualvm aware of clojure fns, I'll be very happy.


On Friday, December 9, 2016 at 3:52:38 PM UTC-8, Ghadi Shayban wrote:
>
> The stacktrace should be pointing to the correct file & line number -- no 
> need to reverse engineer the mangling.  If it's not for some reason, file a 
> bug.  (It's helpful to eliminate nREPL / lein middleware in case something 
> is transforming the printing of traces)
> If you are missing a trace when the JVM JITs your code, run with -XX:-
> *OmitStackTraceInFastThrow* 
>
> On Friday, December 9, 2016 at 6:25:24 PM UTC-5, Brian Craft wrote:
>>
>> Yes, but not very practical: since I don't know which one to change, this 
>> would be a huge rewrite of code to eliminate #() and (fn []).
>>
>>
>> On Friday, December 9, 2016 at 3:16:06 PM UTC-8, Alex Engelberg wrote:
>>>
>>> If you're seeing "fn_123", it's probably coming from an anonymous 
>>> function. Giving those functions a name with the (fn my-name [] ...) syntax 
>>> will make the stack trace a little easier to decipher:
>>>
>>> user=> ((fn [] (/ 1 0)))
>>>
>>> ArithmeticException Divide by zero  clojure.lang.Numbers.divide 
>>> (Numbers.java:158)
>>>
>>> user=> (pst)
>>>
>>> ArithmeticException Divide by zero
>>> clojure.lang.Numbers.divide (Numbers.java:158)
>>> clojure.lang.Numbers.divide (Numbers.java:3808)
>>> user/eval20851/fn--20852 (form-init8836862334241327650.clj:1)
>>> ​...​
>>>
>>> nil
>>> user=> ((fn my-fn-with-a-name [] (/ 1 0))
>>>
>>> ArithmeticException Divide by zero  clojure.lang.Numbers.divide 
>>> (Numbers.java:158)
>>> user=> (pst)
>>> ArithmeticException Divide by zero
>>> clojure.lang.Numbers.divide (Numbers.java:158)
>>> clojure.lang.Numbers.divide (Numbers.java:3808)
>>> user/eval20857/my-fn-with-a-name--20858 
>>> (form-init8836862334241327650.clj:1)
>>> ​...​
>>>
>>> nil
>>>
>>> On Fri, Dec 9, 2016 at 3:00 PM, Brian Craft  wrote:
>>>
 Trying to profile some code, and the stack traces look like

 clojure.something0
   clojure.something1
clojure.something2
  
   clojure.something100
  foo$fn_1000$fn_1002$fn_10003.invoke()


 How can I figure out what that last function is? I can access the 
 symbol from the repl, but no idea how to connect it to my code.

 -- 
 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: finding clojure functions from the mangled names

2016-12-09 Thread Sean Corfield
How big a piece of code is clojure.something100/foo ?

 

That sort of name indicates nested anonymous functions inside foo, nested three 
deep in this case. That should narrow it down quite a bit.

 

(if you give us real names, that might help, especially if it’s in a well-known 
third party library – or you can post the containing ‘foo’ function for us to 
see?)

 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

 

On 12/9/16, 3:00 PM, "Brian Craft"  wrote:

 

Trying to profile some code, and the stack traces look like

 

clojure.something0

  clojure.something1

   clojure.something2

 

  clojure.something100

 foo$fn_1000$fn_1002$fn_10003.invoke()

 

 

How can I figure out what that last function is? I can access the symbol from 
the repl, but no idea how to connect it to my code.

 

 

-- 
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: finding clojure functions from the mangled names

2016-12-09 Thread Brian Craft
It doesn't, really, because you can't tell how nested functions are in 
clojure due to all the macros. In my code it wasn't nested at all, but I 
see now that defmethod and core.match added nested anonymous functions.

On Friday, December 9, 2016 at 4:32:51 PM UTC-8, Sean Corfield wrote:
>
> How big a piece of code is clojure.something100/foo ?
>
>  
>
> That sort of name indicates nested anonymous functions inside foo, nested 
> three deep in this case. That should narrow it down quite a bit.
>
>  
>
> (if you give us real names, that might help, especially if it’s in a 
> well-known third party library – or you can post the containing ‘foo’ 
> function for us to see?)
>
>  
>
> Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
>  
>
> On 12/9/16, 3:00 PM, "Brian Craft"  
> on behalf of craft...@gmail.com > wrote:
>
>  
>
> Trying to profile some code, and the stack traces look like
>
>  
>
> clojure.something0
>
>   clojure.something1
>
>clojure.something2
>
>  
>
>   clojure.something100
>
>  foo$fn_1000$fn_1002$fn_10003.invoke()
>
>  
>
>  
>
> How can I figure out what that last function is? I can access the symbol 
> from the repl, but no idea how to connect it to my code.
>
>  
>
>  
>

-- 
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: finding clojure functions from the mangled names

2016-12-09 Thread Sean Corfield
Ah yes, macros… That can throw a wrench in things b/c your source code and the 
compiled code no longer bear much resemblance to each other L

 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

 

On 12/9/16, 4:49 PM, "Brian Craft"  wrote:

 

It doesn't, really, because you can't tell how nested functions are in clojure 
due to all the macros. In my code it wasn't nested at all, but I see now that 
defmethod and core.match added nested anonymous functions.

 

 

-- 
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: Spec of conform of spec

2016-12-09 Thread Leon Grapenthin
Alex, I thought about this and it appears to be a convenience problem. Spec 
is e. g. excellent to parse a e. g. a Query DSL (which is my current side 
project) via conform. But then you have that large data structure that you 
want to break down and operate on in several functions. So you need to have 
the specs for the conformed structure built by spec. 

I found a surprisingly easy way to do so:

(defmacro conformed
  "Takes a spec conformable and unformable spec.  Returns a spec that
  validates and generates conformed values per spec."
  [spec]
  `(s/with-gen (fn [v#]
 (try
   (= v#
  (s/conform ~spec (s/unform ~spec v#)))
   (catch Throwable _# false)))
 (fn []
   (gen/fmap (fn [v#] (s/conform ~spec v#))
 (s/gen ~spec)

Do you think it's a good idea to pursue this way?

Kind regards, 
 Leon.
On Thursday, September 1, 2016 at 2:33:17 PM UTC+2, Alex Miller wrote:
>
> I think you may be confusing the return value of a predicate value (acting 
> as a spec) with the return value of the function passed to conformer.
>
> In the former case a predicate function's return value is a logically 
> truthy value and a return of nil or false indicates the value is invalid.
>
> The function passed to a conformer is expected to return either a 
> conformed value or ::s/invalid.
>
>

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


freqsort

2016-12-09 Thread dimitris

Hi all,

I was just playing about with sorting  the other day and I came up with 
the following. I'll say upfront that performance wasn't my goal, however 
the performance of `freqsort` caught me completely off guard! It's 
surprisingly decent to say the least... I'm truly amazed given that my 
grandma could literally read this (!!!) :)



(defn sorted-frequencies
  "Same as `clojure.core/frequencies` but returns a sorted-map." [coll]
  (let [?increment (fnil unchecked-inc0)]
(reduce (fn [counts x]
  (update counts x ?increment))
(sorted-map)
coll)))

(defn freqsort
  "A sorting technique based on `clojure.core/frequencies` + sorted-map 
(for the actual sorting), and transducers (for the final concatenation), 
exhibiting very decent performance (for 1E6 elements just above 2x the 
core fn)." [xs]

  (into [] (comp (map (fn [[x n]]
;; the x occurred n times (repeat n x)))
 cat)
(sorted-frequencies xs)))


I've seen/implemented various other sorting algorithms in Clojure, and 
this is by far the fastest and cleanest one i was able to find/write.


;;=REPL_OUTPUT=

(use '(criterium.core))

(def data (doall (repeatedly 100 (partial rand-int 5000

=> #'treajure.encore/data

(quick-bench (freqsort data))
Evaluation count : 9450 in 6 samples of 1575 calls.
 Execution time mean : 63.675363 µs
Execution time std-deviation : 1.144335 µs
   Execution time lower quantile : 62.496493 µs ( 2.5%)
   Execution time upper quantile : 65.035663 µs (97.5%)
   Overhead used : 1.979934 ns
=> nil

(quick-bench (sort data))
Evaluation count : 36642 in 6 samples of 6107 calls.
 Execution time mean : 16.496481 µs *4x faster than `freqsort`*
Execution time std-deviation : 134.094210 ns
   Execution time lower quantile : 16.361877 µs ( 2.5%)
   Execution time upper quantile : 16.641270 µs (97.5%)
   Overhead used : 1.979934 ns
=> nil
(def data (doall (repeatedly 1000 (partial rand-int 5000

=> #'treajure.encore/data

(quick-bench (freqsort data))
Evaluation count : 678 in 6 samples of 113 calls.
 Execution time mean : 929.610743 µs
Execution time std-deviation : 83.275723 µs
   Execution time lower quantile : 885.340646 µs ( 2.5%)
   Execution time upper quantile : 1.073217 ms (97.5%)
   Overhead used : 1.979934 ns

Found 1 outliers in 6 samples (16.6667 %)
low-severe 1 (16.6667 %)
 Variance from outliers : 15.7652 % Variance is moderately inflated by 
outliers

=> nil

(quick-bench (sort data))
Evaluation count : 1986 in 6 samples of 331 calls.
 Execution time mean : 305.248705 µs *3x faster than 
`freqsort`*

Execution time std-deviation : 2.572377 µs
   Execution time lower quantile : 303.218408 µs ( 2.5%)
   Execution time upper quantile : 309.553407 µs (97.5%)
   Overhead used : 1.979934 ns

Found 1 outliers in 6 samples (16.6667 %)
low-severe 1 (16.6667 %)
 Variance from outliers : 13.8889 % Variance is moderately inflated by 
outliers

=> nil
(def data (doall (repeatedly 1 (partial rand-int 5000

=> #'treajure.encore/data

(quick-bench (freqsort data))
Evaluation count : 54 in 6 samples of 9 calls.
 Execution time mean : 12.557872 ms
Execution time std-deviation : 976.670436 µs
   Execution time lower quantile : 12.031381 ms ( 2.5%)
   Execution time upper quantile : 14.247191 ms (97.5%)
   Overhead used : 1.979934 ns

Found 1 outliers in 6 samples (16.6667 %)
low-severe 1 (16.6667 %)
 Variance from outliers : 15.4707 % Variance is moderately inflated by 
outliers

=> nil

(quick-bench (sort data))
Evaluation count : 150 in 6 samples of 25 calls.
 Execution time mean : 4.058038 ms *3x faster than `freqsort`*
Execution time std-deviation : 86.703920 µs
   Execution time lower quantile : 3.979264 ms ( 2.5%)
   Execution time upper quantile : 4.159908 ms (97.5%)
   Overhead used : 1.979934 ns
=> nil
(def data (doall (repeatedly 10 (partial rand-int 5000

=> #'treajure.encore/data

(quick-bench (freqsort data))
Evaluation count : 6 in 6 samples of 1 calls.
 Execution time mean : 132.138750 ms
Execution time std-deviation : 10.379214 ms
   Execution time lower quantile : 138.162338 ms ( 2.5%)
   Execution time upper quantile : 161.986112 ms (97.5%)
   Overhead used : 1.979934 ns

Found 1 outliers in 6 samples (16.6667 %)
low-severe 1 (16.6667 %)
 Variance from outliers : 15.2716 % Variance is moderately inflated by 
outliers

=> nil

(quick-bench (sort data))
Evaluation count : 12 in 6 samples of 2 calls.
 Execution time mean : 57.354588 ms *~2x faster than 
`freqsort`*

Execution time std-deviation : 1.234770 ms
   Execution time lower quantile : 55.048058 ms ( 2.5%)
   Execution time upper quantile : 58.109885 ms (97.5%)
   

Closure for object pattern? A good idea?

2016-12-09 Thread Didier
I'm wondering what everyone thinks of using closures to mimic a simplistic 
object system in Clojure? I'm not sure what to think of it yet, but the 
idea is that you wrap object fields inside a closed function, and it 
returns a map of methods that operates over those fields.

Here's an example of using this pattern to implement a StopWatch:

(import [java.lang System])
(defn new-stopwatch []
  (let [start-time (atom nil)
elapsed (atom 0)]
{:start (fn []
  (when (nil? @start-time)
(reset! start-time (System/currentTimeMillis
 :stop (fn []
 (when-not (nil? @start-time)
   (reset! elapsed
   (+ @elapsed
  (- (System/currentTimeMillis) @start-time)))
   (reset! start-time nil))
 @elapsed)
 :reset (fn []
  (reset! start-time nil)
  (reset! elapsed 0)
  @elapsed)
 :elapsed (fn []
(if-not (nil? @start-time)
(- (System/currentTimeMillis) @start-time)
@elapsed))}))

(let [sw1 (new-stopwatch)
  sw2 (new-stopwatch)]
  ((:start sw1))
  ((:start sw2))
  (Thread/sleep 100)
  ((:reset sw1))
  ((:start sw1))
  (println (str "Elapsed for SW1: " ((:elapsed sw1
  (println (str "Elapsed for SW2: " ((:elapsed sw2
  (Thread/sleep 100)
  (println (str "SW1: " ((:stop sw1
  (println (str "SW2: " ((:stop sw2)

I find for certain things, like a stopwatch, this pattern is actually 
pretty nice. I can't think of any alternative way to do this in Clojure 
that I'd like better actually.

What are your thoughts?

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