Re: Understanding vars

2013-03-22 Thread Nicola Mometto
Opened ticket with fix + test http://dev.clojure.org/jira/browse/CLJ-1187 Mark Engelberg writes: > On Tue, Mar 19, 2013 at 12:57 AM, Bronsa wrote: > >> If I remember correctly, this is a bug due to the fact that constant empty >> literals are handled in a special way from the compiler. >> >> >

Re: Understanding vars

2013-03-19 Thread Bronsa
I remember finding out about it a few months ago. I don't know whether or not there is a jira ticket for it, I'll check out. If nobody can get a patch for this, I'll try and see if I can work out one in the next days Il giorno 19/mar/2013 09.02, "Mark Engelberg" ha scritto: > On Tue, Mar 19, 201

Re: Understanding vars

2013-03-19 Thread Mark Engelberg
On Tue, Mar 19, 2013 at 12:57 AM, Bronsa wrote: > If I remember correctly, this is a bug due to the fact that constant empty > literals are handled in a special way from the compiler. > > Interesting. I see you are correct that the problem only occurs on metadata attached to an empty literal. S

Re: Understanding vars

2013-03-19 Thread Marko Topolnik
Indeed: (def ecr (with-meta [1] {:amazing true})) (def ^:const c ecr) (meta ecr) -> {:amazing true} (meta c) -> {:amazing true} On Tuesday, March 19, 2013 8:57:28 AM UTC+1, Nicola Mometto wrote: > > If I remember correctly, this is a bug due to the fact that constant empty > literals are handle

Re: Understanding vars

2013-03-19 Thread Bronsa
If I remember correctly, this is a bug due to the fact that constant empty literals are handled in a special way from the compiler. Il giorno 19/mar/2013 08.49, "Marko Topolnik" ha scritto: > The way speed is achieved for :const is that it is given the same >> treatment as Java's *compile-time co

Re: Understanding vars

2013-03-19 Thread Marko Topolnik
> > The way speed is achieved for :const is that it is given the same > treatment as Java's *compile-time constants*, so you're not even touching > the var when you refer to it by name. Now, *meta* could be accepted as a > special case, explicitly detected by the compiler, but that mechanism wo

Re: Understanding vars

2013-03-19 Thread Marko Topolnik
On Tuesday, March 19, 2013 4:41:33 AM UTC+1, puzzler wrote: > On Mon, Mar 18, 2013 at 8:31 PM, Kemar >wrote: > >> Explicitly derefing the var and calling meta on it works: >> >> (meta @#'c) -> {:amazing true} >> >> No idea as to why though... >> > > Quirky. I assume that explicitly derefing the v

Re: Understanding vars

2013-03-18 Thread Mark Engelberg
On Mon, Mar 18, 2013 at 8:31 PM, Kemar wrote: > Explicitly derefing the var and calling meta on it works: > > (meta @#'c) -> {:amazing true} > > No idea as to why though... > Quirky. I assume that explicitly derefing the var defeats the speed benefits of ^:const, yes? -- -- You received thi

Re: Understanding vars

2013-03-18 Thread Kemar
Explicitly derefing the var and calling meta on it works: (meta @#'c) -> {:amazing true} No idea as to why though... Am Dienstag, 19. März 2013 03:45:57 UTC+1 schrieb puzzler: > > On Mon, Mar 18, 2013 at 12:38 PM, Marko Topolnik > > > wrote: > >> This is just about the same as >> >> (def ^:co

Re: Understanding vars

2013-03-18 Thread Mark Engelberg
On Mon, Mar 18, 2013 at 12:38 PM, Marko Topolnik wrote: > This is just about the same as > > (def ^:const pi (compute-estimate-of-pi)) > > > OK, just tried out ^:const in my code and it seems to strip off any meta data associated with the object stored in the var. That ruins its utility for my pu

Re: Understanding vars

2013-03-18 Thread Marko Topolnik
On Monday, March 18, 2013 7:16:17 PM UTC+1, puzzler wrote: > > It used to be that a common way to refactor this for best performance > would be: > > (let [pi (compute-estimate-of-pi)] > (defn f [x] > ; Do stuff with pi here > )) > This is just about the same as (def ^:const pi (compute