I think the key point is that the read transaction doesn't change the
value,so it will see the snapshots before or after ref1 updated,and both of
two snapshot could be treated consistently.
All reads of Refs will see a consistent snapshot of the 'Ref world' as of
the starting point of the transact
Hi,
We're all agreed that the behaviour I'm seeing is because the READ
transaction is re-starting. It sounds like the community thinks that's the
right behaviour and I'm happy to be educated
I don't believe that the READ transaction should need to restart just
because the underlying refs chan
Hi,
I know your meaning.But it is real that the read transaction is
restarted,you can observer it by stm-profile:
https://github.com/killme2008/stm-profiler
(.start (Thread.
#(do (Thread/sleep 1)
(prn (ref-stats r1)
(Thread/sleep 2000)
r1 statistics:
{:de
Hi Stu,
The point is that there's no reason for the READ transaction to restart, it
has only made reads of refs and those reads should be consistent with each
other from the snapshot of the the ref world as per...
In practice, this means:
1. All reads of Refs will see a consistent snapshot of
On Mon, Apr 16, 2012 at 10:18 PM, larry wrote:
> On Monday, April 16, 2012 10:02:48 AM UTC-7, Cedric Greevey wrote:
>> (-> 3 ((partial f 2))) should also work.
> I just wrote that it DOESN'T WORK. That's the point of the question.I
> should get 5 instead I get
> t#
Hint: (-> 3 ((partial f 2) #_"a
user=> (defn f[x y] (+ x y))
#'user/f
user=> (-> 3 ((partial f 2)))
5
It must works :). Please notice the extra parentheses.
2012/4/17 larry
>
>
> On Monday, April 16, 2012 10:02:48 AM UTC-7, Cedric Greevey wrote:
>>
>> (-> 3 ((partial f 2))) should also work.
>>
>
>
> I just wrote that it DOES
Compare the number of brackets in Cedric's example to yours.
Ambrose
On Tue, Apr 17, 2012 at 1:18 PM, larry wrote:
>
>
> On Monday, April 16, 2012 10:02:48 AM UTC-7, Cedric Greevey wrote:
>>
>> (-> 3 ((partial f 2))) should also work.
>>
>
>
> I just wrote that it DOESN'T WORK. That's the point
On Monday, April 16, 2012 10:02:48 AM UTC-7, Cedric Greevey wrote:
>
> (-> 3 ((partial f 2))) should also work.
>
I just wrote that it DOESN'T WORK. That's the point of the question.I
should get 5 instead I get
t#
--
You received this message because you are subscribed to the Google
Group
Hi
Transaction "read point" is changed every time when transaction is
started or retried.So the result is all right.If you want the ref1 cloud
not be modified by other transactions ,you can use "ensure":
(defn deref-delay-deref [ref1 ref2 delay]
(.start
(Thread.
> So if you create 2 refs and then read them in a transaction they could be
> inconsistent with each other. i.e they won't necessarily return the value
> the ref had at the start of the transaction.
>
> However, if you give the refs some history by updating them in a prior
> transaction, then the t
> Hi,
>
> [disclojure]: I've asked about this on SO, but figured out what was happening
> myself[1] and that led to this enquiry.
>
>
> It seems that the consistency of refs within an STM transaction (dosync)
> depends on whether the ref has history.
>
> So if you create 2 refs and then read
I am working on a tiny web server and http client in clojure and java.
It's using java's async Socket IO.
https://github.com/shenfeng/http-kit
The code is mostly written in java, It will expose a nice clojure API.
My goal are async, fast, RAM efficiency, clean and compact code.
I write it for Rssmi
On Mon, Apr 16, 2012 at 7:30 PM, Adam Markham wrote:
> I actually made an error when typing the code out in my message, so I
> had no 'ns' in front of the namespace name. The issue was as you said
> Mark I used hyphens but they needed to be underscores. I went into the
> project classes folder and
I actually made an error when typing the code out in my message, so I
had no 'ns' in front of the namespace name. The issue was as you said
Mark I used hyphens but they needed to be underscores. I went into the
project classes folder and found that the package had underscores in
its name. Something
On Tue Apr 17 00:21 2012, Rostislav Svoboda wrote:
> I just quickly tried out the lein-tarsier and I'm getting:
>
> $ lein vimclojure
> Starting VimClojure server on 127.0.0.1, port 2113
> Happy hacking!
>
> (now I open http://127.0.0.1:2113 in my browser)
>
> java.lang.OutOfMemoryError: Java he
FYI setting :jvm-opts ["-Xmx2672m"] in the project.clj produces the
same error and I can't set more than 2672 MB otherwise JVM complains
about "Error: Could not create the Java Virtual Machine."
Bost
On 17 April 2012 00:21, Rostislav Svoboda wrote:
> I just quickly tried out the lein-tarsier a
I just quickly tried out the lein-tarsier and I'm getting:
$ lein vimclojure
Starting VimClojure server on 127.0.0.1, port 2113
Happy hacking!
(now I open http://127.0.0.1:2113 in my browser)
java.lang.OutOfMemoryError: Java heap space
at vimclojure.nailgun.NGSession.run(NGSession.java:1
Wow, that really blew me away.
--
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
Hi,
[disclojure]: I've asked about this on SO, but figured out what was
happening myself[1] and that led to this enquiry.
It seems that the consistency of refs within an STM transaction (dosync)
depends on whether the ref has history.
So if you create 2 refs and then read them in a transaction
Thanks Michal Marczyk!
This is a really important addition.
On Mon, Apr 16, 2012 at 2:15 PM, David Nolen wrote:
> Thanks to Michal Marczyk we're closing in on PersistentHashMaps:
>
> http://jsperf.com/cljs-persistent-hash-map-tiny-assoc
> http://jsperf.com/cljs-persistent-hash-map-large-assoc
>
Thanks to Michal Marczyk we're closing in on PersistentHashMaps:
http://jsperf.com/cljs-persistent-hash-map-tiny-assoc
http://jsperf.com/cljs-persistent-hash-map-large-assoc
http://jsperf.com/cljs-persistent-hash-map-access
Performance is looking pretty good and, as usual, very stellar on V8.
Da
On Apr 16, 11:07 am, Jay Fields wrote:
> If you go down that path, I think vec
> (http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/vec)
> is worth looking at.
>
> I've always understood that vec turns lists into vectors, but leaves
> vectors alone... which looks like what you
If you go down that path, I think vec
(http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/vec)
is worth looking at.
I've always understood that vec turns lists into vectors, but leaves
vectors alone... which looks like what you are doing.
On Mon, Apr 16, 2012 at 1:02 PM, kurthar
(-> 3 ((partial f 2))) should also work.
--
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 unsubsc
On Apr 16, 10:45 am, Stuart Sierra
wrote:
> As an alternative, you could quote the entire expression (you can quote
> anything, not just lists) when copying data structures into a test.
>
> -S
It never occurred to me to do that so I guess that works...
As my alternative, I went off and wro
Sorry, I meant to link this post:
http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux/
On Mon, Apr 16, 2012 at 12:58 PM, Jay Fields wrote:
> reading material:
> http://blog.fogus.me/2009/09/04/understanding-the-clojure-macro/
>
> When you say (-> 3 (partial f 2)) that evaluates to (partial 3
reading material:
http://blog.fogus.me/2009/09/04/understanding-the-clojure-macro/
When you say (-> 3 (partial f 2)) that evaluates to (partial 3 f 2) -
which is obviously not what you want.
Likewise, (-> 3 fp) expands to (fp 3), which works fine, as you noticed.
The important thing to remember
I trying to grok partial and -> so I have the following example.
(defn f[x y] (+ x y))
((partial f 2) 3) works as expected , returning 5
but if I try to use ->
(-> 3 (partial f 2))
I get #
But if I first define
(def fp (partial f 2))
then
(-> 3 fp) returns 5 as expected
What's going on ?
I might be wrong, but I think that would cause (add-item 1 {:prop
"here"}) to call the wrong defmethod (should call 4th, calls 2nd)
On Mon, Apr 16, 2012 at 12:47 PM, Ambrose Bonnaire-Sergeant
wrote:
> This should do the trick:
>
> (defmulti add-item (fn [i & other] (class i))
>
> Thanks,
> Ambros
note, I didn't test any of these, but they should work (possibly with
a tweak or 2)
There's quite a few ways to do this, here's one.
(defmulti add-item (fn [& args] (condp count args 0 :none 1 (class
(first args)) :default))
(defmethod add-item :none (add-item nil nil))
(defmethod add-item Intege
This should do the trick:
(defmulti add-item (fn [i & other] (class i))
Thanks,
Ambrose
On Mon, Apr 16, 2012 at 5:33 AM, James Thornton wrote:
> How do you use defmulti to create a function with a variable number of
> args?
>
> For example, add-item is wrapping a Java method that can take a var
As an alternative, you could quote the entire expression (you can quote
anything, not just lists) when copying data structures into a test.
-S
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.
Frequently when working in the repl I want to take a datastructure and
copy it into a test, however if that datastructure contains lists or
more often lazy-seqences these are printed within unquoted (), so when
I copy the result into my test I need to replace these lists with
vectors or quote them.
How do you use defmulti to create a function with a variable number of args?
For example, add-item is wrapping a Java method that can take a variable
number of args, and so here I am trying to make add-item take zero, one, or
two args. Notice there are two singe-arg funcs -- each taking a differ
Thanks. Ended up going the Clojure 1.4 instant literal way as I just
wanted to read and write the dates not use them for anything else.
Thanks,
Adam
On Apr 16, 3:37 pm, David Powell wrote:
> > How can I store the date in a text file and read it back without
> > falling back on Java serializatio
Does app.two.b have a hyphen? If so, make it an underscore when importing.
I've been bitten by that issue before.
Also, +1 to correct names suggested by Vinzent.
-M
On Thursday, April 12, 2012 1:03:49 PM UTC-5, Adam Markham wrote:
>
> I have two namespaces as follows:
>
> (ns app.one.a
>
Thanks for the suggestion. This ended up being just what I was looking for.
I wrote a version that used this, then went to try the analyze library
recently announced (in hopes of getting line numbers). The analyze library
depends on a beta release of Clojure 1.4, and I decided just to stick with
I would serialize to json and save the dates in millis. That's been
working for me for quite awhile.
Cheers, Jay
On Mon, Apr 16, 2012 at 10:29 AM, Adam Markham wrote:
> I want to save a list of Clojure maps to a text file. The problem is I
> have a :date key which contains a java.util.Date objec
I just checked the http://clojure.org/cheatsheet seing there just the
old version without any tooltips. Would anyone put there a new one
with tooltips? Thx
Bost
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to cloj
> How can I store the date in a text file and read it back without
> falling back on Java serialization?
Upgrade to Clojure 1.4, which includes extensible support for parsing
and serializing custom data types, with dates being one of the
built-in types. It will all work automatically.
--
Dave
I want to save a list of Clojure maps to a text file. The problem is I
have a :date key which contains a java.util.Date object, At the moment
I am using:
(spit "file.txt" clj-map)
to save the file. However the dates are printed in the format #
How can I store the date in a text file and read it
On Apr 15, 1:45 am, Anto wrote:
> I want to install clojure version 1.3, which I guess is the latest.
>
> I tried "sudo apt-get install clojure" which installs clojure 1.1 by
> default. I use Ubuntu 10.10
>
> Thanks in advance.
Hi, Anto. I've got some beginner instructions written up at
http://ww
On Apr 15, 8:25 pm, Nicolas Buduroi wrote:
> I'm working on a turn-based game and I'm looking for a good way to manage
> states. In the game each turn is composed of multiple phases. I started by
> using atoms for the phases field (this is a sequence of functions) in a
> record and realized that i
43 matches
Mail list logo