Re: Immutable or Effectively Immutable?

2014-05-16 Thread Gary Verhaegen
"It will also see versions of any object or array referenced by those
final fields that are **at least as up-to-date as the final fields**
are."

To me this means that the value of the final field will be correctly
published **as of the time it was assigned**. So in your example,
there are two problems, I think:

* The modification that is done at the second line of the constructor
of Foo is **not**, in my understanding, safely published, since it is
"more recent" than the final field's assignment (reversing the two
lines *would*, in my understanding, safely publish the array, though
it would still not guarantee an ordering between the fill(1) and
fill(2) operations in this case);
* The value of the bytes array, when the second thread gets hold of
it, is not specified: the bytes variable itself is volatile, but not
its content, so the assignment to bytes must have occurred, but not
the filling with ones.

So, since the previous value of (the contents of) bytes is not
specified, and the next value of bytes is not safely published, in my
view, for this code, all bets are off as to the value seen by the
first thread on the "match" line. No combination of ones and twos
would surprise me (and I'm not even so sure about zeroes).

On 9 May 2014 17:41, Mike Fikes  wrote:
> Thanks Alexandru! That was insightful. :)
>
> Even the JLS's (non-normative?) text is confusing IMHO. Section 17.5 ends
> with this paragraph:
>
> The usage model for final fields is a simple one. Set the final fields for
> an object in that object's constructor. Do not write a reference to the
> object being constructed in a place where another thread can see it before
> the object's constructor is finished. If this is followed, then when the
> object is seen by another thread, that thread will always see the correctly
> constructed version of that object's final fields. It will also see versions
> of any object or array referenced by those final fields that are at least as
> up-to-date as the final fields are.
>
> If you read that paragraph, it would lead you to believe the bit in bold
> would be applicable to the program below. It seems that the key is, as you
> pointed out, simply extending the concept of "this escaping" to cover
> mutable references stored during construction.
>
> import java.util.Arrays;
>
> public class Main {
>
> static class Foo {
> final byte[] bytes;
> Foo(byte[] bytes) {
> this.bytes = bytes;
> Arrays.fill(this.bytes, (byte) 2);
> }
> }
>
> static volatile byte[] bytes;
> static volatile Foo foo;
>
> public static void main(String[] args) {
>
> new Thread(new Runnable() {
> public void run() {
> // Create an array filled with 1s and spin for other thread
> bytes = new byte[1024*1024];
> Arrays.fill(bytes, (byte) 1);
> while (foo == null) {}
>
> // Check to see if we get the array contents set by other
> thread
> byte[] expected = new byte[1024*1024];
> Arrays.fill(expected, (byte) 2);
> boolean match = Arrays.equals(expected, foo.bytes);
> System.out.println(match); // Will print false at times
> }
> }).start();
>
> new Thread(new Runnable() {
> public void run() {
> // Spin for first thread
> while (bytes == null) {}
>
> // Create an "immutable" object using bytes, while mutating
> bytes prior to construction completion and publication
> foo = new Foo(bytes);
> }
> }).start();
> }
> }
>
>
> On Thursday, May 8, 2014 4:43:10 PM UTC-4, Alexandru Nedelcu wrote:
>>
>> On Wed, May 7, 2014 at 6:31 AM, Alex Miller  wrote:
>>>
>>> It does matter with regard to visibility across threads - your example
>>> does not use a synchronization mechanism and there is no guarantee that
>>> other threads will ever see those changes (so don't ever ever do that :).
>>> But if you stick to the normal Clojure apis, all is good. I'd highly
>>> recommend reading JCIP to dive into the details.
>>>
>>> Final field freeze is particularly weird and it baked my noodle when I
>>> first encountered it - here's a blog I wrote about it approx 697 years ago
>>> in internet time (and Brian Goetz backs me up in the comments :)
>>> http://tech.puredanger.com/2008/11/26/jmm-and-final-field-freeze/
>>
>> I believe that while JCIP is useful, it is also confusing, because it is
>> trying to explain Java’s memory model in layman’s terms. I recently
>> experienced “enlightenment”, by making an effort to understand how things
>> work at a lower level.
>>
>> Happens-before relationships / ordering guarantees are given by the
>> compiler, in combination with the CPU, with the rules being implied by usage
>> of memory fences (barriers). Without ordering guarantees, several things can
>> happen - the compiler cou

Re: clojurescript, sourcemaps, and debugging info

2014-05-16 Thread Thomas Heller
Its Chrome, no way around it AFAICT. FWIW you can mouseover the filename in 
the console and the title popup will show the entire URL to the file.

On Friday, May 16, 2014 5:45:28 AM UTC+2, t x wrote:
>
> Hi, 
>
> * background: 
>
>   * I have clojurescript + lein cljsbuild auto working perfectly fine. 
>
>   * I have source maps working (when I click on a file in Chrome, it 
> jumps me to the corresponding *.cljs file) 
>
>
> * problem I am facing: 
>
>   * I like to name my modules: 
>
> foo/public.cljs 
> foo/other-stuff.cljs 
>
> bar/public.cljs 
> bar/other-stuff.cljs 
>
>   Now, Chrome + clojurescript (not sure who is at fault) appears to 
> display not the _full name_, but only the _last part of the pathname_, 
> so I get a bunch of lines saying things like: 
>
>public.cljs:23 
>public.cljs:68 
>
>   and I have no idea whether it's foo/public.cljs or bar/public.cljs 
> without clicking on it. 
>
>
> * question: 
>
>   Is there anyway to get Chrome / clojurescript to display the full 
> name of the *.cljs file rather than just the last part? 
>
> Thanks! 
>

-- 
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: printing lazy lists

2014-05-16 Thread Phillip Lord

Ah, that's better. Thank you!

Phil

Michał Marczyk  writes:

> Use pr-str:
>
> user=> (str (lazy-seq (list 1 2 3)))
> "clojure.lang.LazySeq@7861"
> user=> (pr-str (lazy-seq (list 1 2 3)))
> "(1 2 3)"
>
> Cheers,
> Michał
>
>
> On 15 May 2014 16:29, Phillip Lord  wrote:
>>
>>
>> I am trying to dump a representation of the contents of a list to file.
>> I've recently changed how I generated this list and it's now lazy (not really
>> by design more by side-effect, if you will excuse the poor choice of words).
>>
>> I was using
>>
>> (spit "file" (str lst "\n"))
>>
>> which worked quite nicely, but now it is failing. The problem is that I get a
>> file full of "clojure.lang.LazySeq@" lines. The problem comes from LazySeq
>> directly, as this demonstration with "range" shows.
>>
>> user> (str (list 1 2 3 4 5 ))
>> "(1 2 3 4 5)"
>> user> (str (range 4))
>> "clojure.lang.LazySeq@e1b83"
>> user> (println (range 4))
>> (0 1 2 3)
>> nil
>>
>>
>> println is using prn and a multimethod to print out. In fact,
>> clojure.lang.LazySeq doesn't implement toString, nor does it's super class.
>>
>> The best solution that I have come up with so far is to do
>>
>> (str (apply list (range 4)))
>>
>> I guess I can see why LazySeq doesn't implement toString by printing
>> everything out, but is there a better way around my problem?
>>
>> Phil
>>
>> --
>> 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.

-- 
Phillip Lord,   Phone: +44 (0) 191 222 7827
Lecturer in Bioinformatics, Email: phillip.l...@newcastle.ac.uk
School of Computing Science,
http://homepages.cs.ncl.ac.uk/phillip.lord
Room 914 Claremont Tower,   skype: russet_apples
Newcastle University,   twitter: phillord
NE1 7RU 

-- 
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, sourcemaps, and debugging info

2014-05-16 Thread Tim Visher
Seems worth a bug report/feature request to the Chrome Dev Tools team.

On Thu, May 15, 2014 at 11:45 PM, t x  wrote:
> Hi,
>
> * background:
>
>   * I have clojurescript + lein cljsbuild auto working perfectly fine.
>
>   * I have source maps working (when I click on a file in Chrome, it
> jumps me to the corresponding *.cljs file)
>
>
> * problem I am facing:
>
>   * I like to name my modules:
>
> foo/public.cljs
> foo/other-stuff.cljs
>
> bar/public.cljs
> bar/other-stuff.cljs
>
>   Now, Chrome + clojurescript (not sure who is at fault) appears to
> display not the _full name_, but only the _last part of the pathname_,
> so I get a bunch of lines saying things like:
>
>public.cljs:23
>public.cljs:68
>
>   and I have no idea whether it's foo/public.cljs or bar/public.cljs
> without clicking on it.
>
>
> * question:
>
>   Is there anyway to get Chrome / clojurescript to display the full
> name of the *.cljs file rather than just the last part?
>
> Thanks!
>
> --
> 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: Leiningen just hangs

2014-05-16 Thread Mark Watson
I suspect it was something of that nature.

Ended up being that someone else was in the process of moving my VM and I 
didn't read my emails :-)

All working now.

On Thursday, May 15, 2014 3:49:08 PM UTC-4, Gary Trakhman wrote:
>
> Oh yea, GC churn can take up a lot of time.  The illusion of 'infinite 
> memory' :-).
>
>
> On Thu, May 15, 2014 at 3:47 PM, Armando Blancas 
> 
> > wrote:
>
>> I've had this problem and I suspect is low memory. It happened often with 
>> an old box with 1G running Fedora 20, but I've also seen it with my laptop 
>> if I leave too many leftover jvm processes running (with 4G allocated for a 
>> virtual box instance); on my 16G mac it never happens. So freeing up some 
>> memory has fixed it for me.
>>
>>
>> On Thursday, May 15, 2014 11:34:36 AM UTC-7, Mark Watson wrote:
>>>
>>> I'm running Leiningen on CentOS 6.5. Everything was working fine, and 
>>> today when I try "lein run" it just hangs. It takes about 15 minutes for 
>>> "lein version" to return.
>>>
>>> The project works fine on my macbook pro, and another CentOS box.
>>>
>>> I deleted ~/.m2 and reinstalled Leiningen. I updated Leiningen. I 
>>> removed and reinstalled Java as well.
>>>
>>> Has anyone else come across this? I have no clue what I did or what the 
>>> problem could be. Any help would be greatly appreciated.
>>>
>>> -bash-4.1$ java -version
>>> java version "1.7.0_55"
>>> OpenJDK Runtime Environment (rhel-2.4.7.1.el6_5-x86_64 u55-b13)
>>> OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
>>>
>>> -bash-4.1$ lein version
>>> Leiningen 2.3.4 on Java 1.7.0_55 OpenJDK 64-Bit Server VM
>>>
>>  -- 
>> 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: citing Clojure and EDN?

2014-05-16 Thread Jony Hudson


On Thursday, 15 May 2014 14:58:50 UTC+1, Phillip Lord wrote:
>
>
> Again, based on the dubious ID that an DOI "makes things citable". 
>
> A URL is already citable! 
>

Well, there's no shortage of broken links out there to suggest that people 
have trouble keeping content associated with stable URLs. The main value of 
DOI, IMHO, is they're an explicit commitment to make something persistently 
available - just what you want for citations.


Jony

-- 
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: What to use use for writing GUI's

2014-05-16 Thread Laurent PETIT
Are you almost ready to provide something a la React.js for JavaFX2 ? :-)


2014-05-04 15:50 GMT+02:00 Timothy Baldridge :

> I highly recommend taking a look again at JavaFX2. The latest version
> (released as part of Java 8 or as a separate jar with Java 7) has a very
> unified API and is a joy to work with.
>
> I've been hacking on a library that provides a data centric API to
> JavaFX2. The cool thing is that most of it is self writing. Since the API
> is so consistent, reflection can be used to discover how most of the
> components work. Here's an example of what the UI description layer looks
> like.
>
>
> https://github.com/halgari/com.tbaldridge.slide/blob/master/src/com/tbaldridge/slide.clj#L266
>
> This library uses core.async to bind components to data. So the binding
> :text<- (bindings/get-in a [:text]) will bind a control's text to whatever
> is in the atom a at the path [:text]. Likewise the :text->
> (bindings/assoc-in a [:text]) will keep the atom up to date with the
> contents of a text box.
>
> I haven't tested this on any platform but Mac, but I've seen tutorials of
> JavaFX2 running on Linux and Windows, so I assume it's all fully cross
> platform.
>
> Timothy
>
>
> On Sun, May 4, 2014 at 4:44 AM, Daniel Kersten  wrote:
>
>> I'm a massive fan of Qt and have done a lot of Qt/QML in C++ in the past,
>> but lately when I've needed to do a GUI (and could use Clojure), I've been
>> making it Web based and using ClojureScript with Om. Since jetty/http-kit
>> run nicely as embedded servers, you could have your application run locally
>> and launch a browser (rather than running it on a server) if you wanted,
>> and if you have the ClojureScript talk to the Clojure "server" through
>> sente, you _almost_ won't even notice its not all plain Clojure since
>> communication looks more or less like a core.async channel.
>>
>> Might be a bit much to learn if you're new to Clojure, though.
>>
>> I haven't used swing or Qt in Clojure, so can't comment on them.
>>
>>
>> On 4 May 2014 10:44, Cecil Westerhof  wrote:
>>
>>> 2014-05-04 10:20 GMT+02:00 Cecil Westerhof :
>>>
>>>


 2014-05-04 10:09 GMT+02:00 Colin Fleming :

 There's really no "only" way to do anything in Clojure, since you can
> always drop down to Java interop. So anything that's available to Java is
> available to Clojure, too. Not all the options have a nice Seesaw-like
> wrapper over it of course, but they're generally still quite usable. I do 
> a
> reasonable amount of Swing work without Seesaw, mostly because it takes a
> while to start up, but Seesaw has a lovely API if that's not such an issue
> for you. Swing is generally a fine option, if you look at IntelliJ you'll
> see it's possible to make it quite pretty and functional, although it's a
> lot of work to get to that stage.
>
> Other options are QTJambi or SWT - I don't know anything about Pivot
> and the demos didn't work for me either in Firefox or Safari but it looks
> like that might be an option too. JavaFX may also be an option, although I
> don't know much about it. Or you can go for more esoteric options like
> embedding Chromium in a native app wrapper and use ClojureScript, which is
> what LightTable and other projects do.
>
> It really depends on your requirements, but the above are all viable
> options.
>

 ​Well, I am a newbie with GUI, so best to start with seesaw if there is
 no real reason not to use Swing I think then. (I do not remember why Swing
 was discouraged.) I have to look into the start-up time. I did not know
 about that.

 By the way: as I understood it JavaFX is only an option if you only
 develop for Windows.

>>>
>>>  ​I see that there is also clj-swing. What would are the advantages of
>>> either compared to the other?
>>>
>>> --
>>> 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.
>>>
>>
>>  --
>> 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
>> clojur

Re: clojurescript, sourcemaps, and debugging info

2014-05-16 Thread t x
Bah, I've reverted to a flat namespace, i.e. foo_internal.cljs,
foo_public.cljs, bar_internal.cljs, bar_public.cljs ... :-)

On Fri, May 16, 2014 at 6:24 AM, Tim Visher  wrote:
> Seems worth a bug report/feature request to the Chrome Dev Tools team.
>
> On Thu, May 15, 2014 at 11:45 PM, t x  wrote:
>> Hi,
>>
>> * background:
>>
>>   * I have clojurescript + lein cljsbuild auto working perfectly fine.
>>
>>   * I have source maps working (when I click on a file in Chrome, it
>> jumps me to the corresponding *.cljs file)
>>
>>
>> * problem I am facing:
>>
>>   * I like to name my modules:
>>
>> foo/public.cljs
>> foo/other-stuff.cljs
>>
>> bar/public.cljs
>> bar/other-stuff.cljs
>>
>>   Now, Chrome + clojurescript (not sure who is at fault) appears to
>> display not the _full name_, but only the _last part of the pathname_,
>> so I get a bunch of lines saying things like:
>>
>>public.cljs:23
>>public.cljs:68
>>
>>   and I have no idea whether it's foo/public.cljs or bar/public.cljs
>> without clicking on it.
>>
>>
>> * question:
>>
>>   Is there anyway to get Chrome / clojurescript to display the full
>> name of the *.cljs file rather than just the last part?
>>
>> Thanks!
>>
>> --
>> 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.

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


Question: defrecord accessor efficiency without protocols

2014-05-16 Thread Dave Tenny
(defrecord Foo [bar])

(:bar (Foo. 1))

Is clojure smart enough to make the :bar lookup O(1) as a known field of 
Foo?  Or is it still a map-like O(logN) lookup?


-- 
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] Automat: better FSMs through combinators

2014-05-16 Thread Sam Ritchie
I'd love to start using more FSM modeling in my web app. Users on 
PaddleGuru move through various states for each regatta - paid, signed 
up, invited, etc, and this feels like the best way to model all of those 
transitions. I'd love to figure out how to use Automat to generate a 
series of validations for my rest API when the app fires up.


Thanks for this!


Alex Hammel 
May 14, 2014 12:23 PM
This looks really, really cool. Good 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 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.
Jason Felice 
May 14, 2014 7:41 AM
Wow, this library looks very useful!

Thanks!
-Jason



--
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.
Colin Fleming 
May 13, 2014 4:55 PM
I'm also very excited about Automat, although I haven't had time to 
look at it closely yet. Ragel is one of my favourite pieces of 
software. Here's an article from Zed Shaw about using state charts for 
networked apps: http://www.zedshaw.com/essays/ragel_state_charts.html. 
I read an article (or an interview, I can't remember) where he 
discussed the state machines in Mongrel in more depth, it was 
fascinating and quite amazing how much it simplified the code, made it 
much more robust and consistently handled tricky corners of HTTP while 
easily supporting things like websockets.


I'll take a look when I get a moment and provide some feedback - in 
particular I'm excited about the possibility of compiling state 
machines without the build time precompile step, I think there are a 
lot of interesting possibilities with this.


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.
Zach Tellman 
May 13, 2014 1:27 PM
https://github.com/ztellman/automat

This has been languishing in my Github for a while, for lack of a few 
finishing touches on the code and documentation.  I think this is one 
of cooler libraries I've written, and beyond the obvious use for 
parsers, the set theoretic operators could be a powerful way to 
specify actions in response to complex browsing behaviors on a site, 
or any other number of things.  I'm excited to see how it's used.


I'm happy to answer any questions.  Suggestions on how to improve the 
documentation are encouraged.


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


Re: Immutable or Effectively Immutable?

2014-05-16 Thread Stuart Halloway
;; I think this shed should be painted red
(def immutable-string
  "foo")

(def ^java.lang.reflect.Field value-field
  (doto (.getDeclaredField String "value")
(.setAccessible true)))

(aset (.get value-field immutable-string) 1 \i)
(aset (.get value-field immutable-string) 2 \e)

(println immutable-string)



On Wed, May 7, 2014 at 11:15 AM, Mike Fikes  wrote:

> I would offer that the key distinction is whether final is used: This
> prescribes what you must do when using the object.
>
> Take Date for example. You can't just pass one directly from one thread
> to another. The receiving thread could read a date associated with
> System.currentTimeMillis() of 0.
>
> But, String, since it uses final on its char[], fundamentally changes
> this. (If the final keyword were not present in String, even though you
> have no way to change its char[], it would be broken with respect to
> threading semantics.)
>
> On Wednesday, May 7, 2014 10:35:04 AM UTC-4, Andy Fingerhut wrote:
>
>> Sorry if I'm beating a dead horse here.
>>
>> I agree that my example is not using published Clojure APIs, and I never
>> do that kind of thing in a Clojure program, except as an example that
>> PersistentVector's are mutable if you use Java APIs instead of restricting
>> yourself to Clojure APIs.  You don't even need to use reflection in Java or
>> know about JVM security policies to mutate them (I am not suggesting that
>> Clojure should be changed in any way here).
>>
>> I've actually got a copy of Java: Concurrency in Practice, and looked up
>> (some of) what they say about immutability.  Here is one definition they
>> give of immutability, with some preceding text.  I have added emphasis to
>> one phrase:
>>
>> "Neither the Java Language Specification nor the Java Memory Model
>> formally defines immutability, but __immutability is *not* equivalent to
>> simply declaring all fields of an object 'final'__.  An object whose fields
>> are all final may still be mutable, since final fields can hold references
>> to mutable objects.
>>
>> An object is *immutable* if:
>> + Its state cannot be modified after construction;
>> + All its fields are 'final'; and
>> + It is *properly constructed* (the 'this' reference does not escape
>> during construction)."
>>
>> I have no argument with PersistentVector satisfying the 2nd and 3rd
>> bullet points above, but (1) seems not to hold.  According to JCIP's
>> definition of effectively immutable ("Objects that are not technically
>> immutable, but whose state will not be modified after publication"),
>> PersistentVector appears to me to be effectively immutable, but not truly
>> immutable.
>>
>> Andy
>>
>>
>> On Tue, May 6, 2014 at 8:31 PM, Alex Miller  wrote:
>>
>>> Hey Andy,
>>>
>>> It does matter with regard to visibility across threads - your example
>>> does not use a synchronization mechanism and there is no guarantee that
>>> other threads will ever see those changes (so don't ever ever do that :).
>>> But if you stick to the normal Clojure apis, all is good. I'd highly
>>> recommend reading JCIP to dive into the details.
>>>
>>> Final field freeze is particularly weird and it baked my noodle when I
>>> first encountered it - here's a blog I wrote about it approx 697 years ago
>>> in internet time (and Brian Goetz backs me up in the comments :)
>>> http://tech.puredanger.com/2008/11/26/jmm-and-final-field-freeze/
>>>
>>> Alex
>>>
>>>
>>> On Tuesday, May 6, 2014 7:35:43 PM UTC-5, Andy Fingerhut wrote:
>>>
 Alex, I may be unfamiliar with the definitions of truly immutable and
 effectively immutable being used here, but if I can mutate the contents of
 a Java Object array that is a final field after an object is constructed,
 does it really matter that much if it is final?  It is trivially easy to
 mutate using Java access.  Here is the example that I mentioned earlier in
 this thread, copied here for convenience:

 user=> (def v [1 2 3])
 #'user/v
 user=> (class v)
 clojure.lang.PersistentVector
 user=> v
 [1 2 3]
 user=> (aset (.tail v) 1 -2)
 -2
 user=> v
 [1 -2 3]

 Andy


 On Tue, May 6, 2014 at 4:49 PM, Alex Miller wrote:

>  The Clojure persistent data structures are truly immutable - all
> fields are final and referred objects are not mutated after construction 
> so
> that freeze occurs.  One obvious exception are the transient variants (
> http://clojure.org/transients). You can look at the code in
> https://github.com/clojure/clojure/tree/master/src/jvm/clojure/lang -
> any of the Persistent*.java.
>
>
> On Tuesday, May 6, 2014 4:11:49 PM UTC-5, Mike Fikes wrote:
>>
>> Are the persistent immutable data structures in Clojure "truly"
>> immutable (using final fields, relying on constructor freezing), or are
>> they mean to be merely effectively immutable (as defined in JICP)?
>>
>  --
> You received this mess

Re: Immutable or Effectively Immutable?

2014-05-16 Thread Mike Fikes
In the sample code I pasted, there is nothing to prevent the fill(1) and 
fill(2) from running concurrently, and essentially write into the same array 
concurrently. My intent was that the fill(1) be complete before the second 
thread proceeds.

A simple change to have the 1st thread instead fill a temporary byte[] followed 
by assigning the temporary reference to the static volatile byte[] causes the 
program to no longer print “false”. 

This behavior, while it doesn't prove anything, is consistent with the JLS 
paragraph I quoted.

But, it doesn't disprove Alexandru's claim either...

-- 
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: implicit :required behavior in Tools.cli is deceptive

2014-05-16 Thread guns
On Thu 15 May 2014 at 10:45:52AM -0700, Bob Larrick wrote:
>
> A single element in the cli-options can be as brief as
>
> ["-p" "--port" "A port number"]
>
> What is non-obvious is that specifying
>
> "--port PORT"
>
> has entirely different semantics than specifying
>
> "--port"

Like I mentioned on the issue page, this is just a shortcut around
passing a `:required` entry with the same information.

The motivation behind this is that the resulting option summary mirrors
the option vectors:

  [["-p" "--port PORT" "A port number" :parse-fn #(Integer/parseInt %)]
   ["-q" "--quiet" "Shhh"]]

  -p, --port PORT  A port number
  -q, --quiet  Shhh

It is easy to tell at a glance that --port requires an option argument,
while --quiet does not.

If you dislike this syntax (which I borrowed from Ruby), you may replace
it with:

  ["-p" "--port" "A port number"
   :required "PORT"
   :parse-fn #(Integer/parseInt %)]

> In the first case the command "lein run -p 3000" will result in an options
> map of {:options {:port 3000}}.

> Can you guess what the same command would produce given the second case?

I would expect that an option flag that has not been marked as requiring
an argument to be a boolean toggle. This is the convention in C's
getopt(1), bash's getopts builtin, Perl's GetOpt::Long, and Ruby's
OptionParser.

> If you're like me, you wouldn't guess {:options {:port true}}. :-/
> It is worth noting that in earlier versions of this library "--port" did
> result in {:options {:port 3000}}, so this is a change in behavior from
> previous versions.

Yes, this is a change. The old tools.cli/cli still exists for people who
do not want to bother with learning a new API (I can sympathize). It has
also been upgraded to use the new option tokenizer.

> The current behavior is neither simple nor easy to understand, and
> complects the behavior of the flag with the definition of the long option.

Again, this is optional sugar. The option vectors are actually compiled
to maps:

(#'clojure.tools.cli/compile-option-specs
  [["-p" "--port PORT" "A port number"]
   [nil  "--host" :required "HOST"]])

->

({:id :port
  :short-opt "-p"
  :long-opt "--port"
  :required "PORT"
  :desc "A port number"}
 {:id :host
  :short-opt nil
  :long-opt "--host"
  :required "HOST"
  :desc nil})

You may, if you like, supply the underlying maps instead of the option
vectors to parse-opts. The option specification is documented here:

https://github.com/clojure/tools.cli/blob/master/src/main/clojure/clojure/tools/cli.clj#L265-L309

> I suggest that this implicit behavior be removed and that all options be
> treated as required unless ":required false" is explicitly declared.
>
> Or perhaps there should be :boolean flag similar to :parse-fn or :default,
> since :required feels a little overloaded.
> That way given "lein run -p 3000", ["-p" "--port" "A port number"] would
> result in {:options {:port 3000}} and
> ["-p" "--port" "A port number" :boolean true] would result in {:options
> {:port true}}.
>
> That would make when a flag will be treated as a boolean explicit
> and obvious, and make this library a little less frustrating and
> foot-gunish.

You are suggesting that "options require arguments by default" is less
implicit than "options are boolean toggles by default". This is unclear
to me.

As to which default is preferable and less surprising, I prefer the
latter since it matches the conventions in C, bash, Perl, and Ruby. My
understanding is that the former is the default on Python. Perhaps this
is the source of our disagreement?

I do agree that the documentation is not clear enough on this matter; I
will ameliorate this later today.

guns


pgp60HSRLzVmo.pgp
Description: PGP signature


Re: Question: defrecord accessor efficiency without protocols

2014-05-16 Thread László Török
Hi,

afaik the Clojure compiler will compile such calls to a direct field
access, i.e. the fastest possible.
This will happen whenever the compiler can infer the type information.
You can facilitate this by using type hints if necessary.

Regards,
Las


2014-05-16 15:44 GMT+01:00 Dave Tenny :

> (defrecord Foo [bar])
>
> (:bar (Foo. 1))
>
> Is clojure smart enough to make the :bar lookup O(1) as a known field of
> Foo?  Or is it still a map-like O(logN) lookup?
>
>
>  --
> 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.
>



-- 
László Török
Checkout Lollyrewards.com  - Giving credit,
getting credit.
Follow us on Twitter @lollyrewards 
Stay up to date on the latest offers by liking our Facebook
page
.

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


Is there a term for non-map collections?

2014-05-16 Thread Mars0i
As Tim McCormack's helpful web page on Collections and Sequences in 
Clojuresays, 
"Newcomers to Clojure are often confused by the collection and 
sequence abstractions and how they relate to one another."   I'd been using 
collections and sequences successfully, but was confused about terminology 
until I read McCormack's explanation.  I have a further question:

Is there are term for collections that are not maps?

Although vectors can function like maps, because they are associative?, and 
functions like find and get treat indexes as if they were map keys, from 
another perspective vectors are just sequences of single elements, not 
sequences of key-val pairs.  This difference shows up in contexts such as 
map :
(map identity [:a :b]) ; ==> (:a :b)
(map identity {1 :a 2 :b}) ; ==> ([1 :a] [2 :b])

Is there a single term that covers vectors, lists, sets, lazy sequences, 
cons's, etc., but not maps?

The only reason that this matters to me is for naming functions, 
parameters, and docstrings.  Sometimes I write a function that will work in 
the intended way only with collections that are not maps.  (For example, 
suppose I write a function that's supposed to operate on vectors, lists, 
sets, or lazy sequences of keywords, what do I call its argument?  
"keyw-coll" is too broad, and "keyw-seq" is too narrow.)

-- 
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: Is there a term for non-map collections?

2014-05-16 Thread Stephen Gilardi

On May 16, 2014, at 12:53 PM, Mars0i  wrote:

> Sometimes I write a function that will work in the intended way only with 
> collections that are not maps.  (For example, suppose I write a function 
> that's supposed to operate on vectors, lists, sets, or lazy sequences of 
> keywords, what do I call its argument?  "keyw-coll" is too broad, and 
> "keyw-seq" is too narrow.)

I think I'd use "kws" or "keywords" in that case. I'd expect a seq of keywords.

I don't think keyw-seq is too narrow though. The items in a seq on a map are 
"map entries" or more generically "pairs", not "keywords".

--Steve

-- 
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: Is there a term for non-map collections?

2014-05-16 Thread Mars0i


On Friday, May 16, 2014 12:09:36 PM UTC-5, squeegee wrote:
>
> I think I’d use “kws” or “keywords” in that case. I’d expect a seq of 
> keywords.
>
> I don’t think keyw-seq is too narrow though. The items in a seq on a map 
> are “map entries" or more generically “pairs”, not “keywords”.
>

OK, but "seq" implies that sets aren't appropriate, but as long as I don't 
care about order, they may be perfectly fine.

-- 
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: Is there a term for non-map collections?

2014-05-16 Thread Stephen Gilardi

On May 16, 2014, at 1:23 PM, Mars0i  wrote:

> I think I'd use "kws" or "keywords" in that case. I'd expect a seq of 
> keywords.
> 
> I don't think keyw-seq is too narrow though. The items in a seq on a map are 
> "map entries" or more generically "pairs", not "keywords".
> 
> OK, but "seq" implies that sets aren't appropriate, but as long as I don't 
> care about order, they may be perfectly fine.

Good point. Technically kw-seq is too narrow because you probably have no need 
to restrict your argument to seqs. The distinction is often blurred because 
many Clojure functions that operate on seqs also directly or indirectly call 
"seq" on their argument. Any coll that's "seqable" will also work.

I think looking at the word kew-seq as an argument name, I would expect to be 
able to pass in colls that are not seqs but are seqable including vector and 
set.

Revising my earlier thought:

I think I'd use "kws" or "keywords" in that case. I'd expect a seq or seqable 
coll whose items are keywords.


--Steve

-- 
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: Propagating data through dependencies

2014-05-16 Thread David Pidcock
What I meant was that you use all b's to generate the max date for B (used as 
input for its dependencies) but simply bundle all b's into B's bill.  You can't 
bill them before or after B because they're effectively line items on B. 

 

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


Looking for help with a Stack Overflow error

2014-05-16 Thread Brad Kurtz
I'm pretty new to Clojure so I'm trying out simple examples to see if I can 
get myself in the functional programming/Lisp mindset. My team lead sends 
out puzzles from his Mensa calendar, and every once in a while I find one 
that seems fun to solve as a Clojure program.

With this particular puzzle, I've tried a couple of different ways of 
"solving" the puzzle, and I decided to try a recursive function. I'm fairly 
certain that what I've done here is not anywhere near ideal, and I'm 
looking for insight into how to better write this solution.

Also, with my latest attempt I seem to be getting a stack overflow error, 
and I'm not quite sure why. I'm pretty sure it has to do with the 
permutation sequence (it's basically 10 factorial, or around 3 million 
sequences), but I don't really know how to better represent this problem in 
Clojure. Can anyone help? Thanks!

https://github.com/bradkurtz/clojure-puzzles/tree/master/billiards

-- 
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: Is there a term for non-map collections?

2014-05-16 Thread Mars0i


On Friday, May 16, 2014 12:46:10 PM UTC-5, squeegee wrote:
>
>
> On May 16, 2014, at 1:23 PM, Mars0i > 
> wrote:
>
> OK, but "seq" implies that sets aren't appropriate, but as long as I don't 
> care about order, they may be perfectly fine.
>
>
> Good point. Technically kw-seq is too narrow because you probably have no 
> need to restrict your argument to seqs. The distinction is often blurred 
> because many Clojure functions that operate on seqs also directly or 
> indirectly call “seq” on their argument. Any coll that’s “seqable” will 
> also work.
>
> I think looking at the word kew-seq as an argument name, I would expect to 
> be able to pass in colls that are not seqs but are seqable including vector 
> and set.
>
> Revising my earlier thought:
>
> I think I’d use “kws” or “keywords” in that case. I’d expect a seq or 
> seqable coll whose items are keywords.
>
>
So there really isn't a term for the category I have in mind, but your 
point, I take it, is that "seq" can do the job, even for sets, despite 
their lack of order, since they are things that will take on an order when 
needed.  

(Keyword was just an illustration.  I had a more general question in mind.  
You really can pass in a map to anything that will take seqs, vectors, and 
sets, in general, but sometimes it's kind of a bizarre thing to do, and 
it's worth conveying that to users (even when the only user is oneself).)

I still would kind of like a special term  If no one has one already, I 
could try to make one up.  Maybe the difference between maps and vectors is 
that, although they both have keys, it's easier to lose vector keys (as in 
the examples with the map function):  "de-keyable", "dekeyed", 
"de-pair-able"?  I don't think this is going to help make my docstrings 
clearer.  

-- 
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: Is there a term for non-map collections?

2014-05-16 Thread Laurent PETIT
For what it's worth, I would either choose "kws"/"keywords" for brevity, or
"keywords-seqable" for explicitness.

All in all, better imprecise but correct than precise and incorrect.

Hope this helps,

-- 
Laurent



2014-05-16 22:38 GMT+02:00 Mars0i :

>
>
> On Friday, May 16, 2014 12:46:10 PM UTC-5, squeegee wrote:
>
>>
>> On May 16, 2014, at 1:23 PM, Mars0i  wrote:
>>
>> OK, but "seq" implies that sets aren't appropriate, but as long as I
>> don't care about order, they may be perfectly fine.
>>
>>
>> Good point. Technically kw-seq is too narrow because you probably have no
>> need to restrict your argument to seqs. The distinction is often blurred
>> because many Clojure functions that operate on seqs also directly or
>> indirectly call “seq” on their argument. Any coll that’s “seqable” will
>> also work.
>>
>> I think looking at the word kew-seq as an argument name, I would expect
>> to be able to pass in colls that are not seqs but are seqable including
>> vector and set.
>>
>> Revising my earlier thought:
>>
>> I think I’d use “kws” or “keywords” in that case. I’d expect a seq or
>> seqable coll whose items are keywords.
>>
>>
> So there really isn't a term for the category I have in mind, but your
> point, I take it, is that "seq" can do the job, even for sets, despite
> their lack of order, since they are things that will take on an order when
> needed.
>
> (Keyword was just an illustration.  I had a more general question in
> mind.  You really can pass in a map to anything that will take seqs,
> vectors, and sets, in general, but sometimes it's kind of a bizarre thing
> to do, and it's worth conveying that to users (even when the only user is
> oneself).)
>
> I still would kind of like a special term  If no one has one already,
> I could try to make one up.  Maybe the difference between maps and vectors
> is that, although they both have keys, it's easier to lose vector keys (as
> in the examples with the map function):  "de-keyable", "dekeyed",
> "de-pair-able"?  I don't think this is going to help make my docstrings
> clearer.
>
> --
> 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: Looking for help with a Stack Overflow error

2014-05-16 Thread Brad Kurtz
I have since fixed the original stack overflow error I was getting, it was 
a result of not using "recur". However, I'm still trying to find the best 
way to actually iterate through the permutations to find the result...

On Friday, May 16, 2014 2:31:26 PM UTC-5, Brad Kurtz wrote:
>
> I'm pretty new to Clojure so I'm trying out simple examples to see if I 
> can get myself in the functional programming/Lisp mindset. My team lead 
> sends out puzzles from his Mensa calendar, and every once in a while I find 
> one that seems fun to solve as a Clojure program.
>
> With this particular puzzle, I've tried a couple of different ways of 
> "solving" the puzzle, and I decided to try a recursive function. I'm fairly 
> certain that what I've done here is not anywhere near ideal, and I'm 
> looking for insight into how to better write this solution.
>
> Also, with my latest attempt I seem to be getting a stack overflow error, 
> and I'm not quite sure why. I'm pretty sure it has to do with the 
> permutation sequence (it's basically 10 factorial, or around 3 million 
> sequences), but I don't really know how to better represent this problem in 
> Clojure. Can anyone help? Thanks!
>
> https://github.com/bradkurtz/clojure-puzzles/tree/master/billiards
>

-- 
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] Throttler: a library for rate limiting

2014-05-16 Thread Don Jackson

On May 14, 2014, at 9:43 AM, Bruno Vecchi  wrote:

> Throttler[1] is a little library I wrote out of need for one of my personal 
> projects. It lets you control the maximum rate of function calls or message 
> transmissions through core.async channels.

This is way cool, thanks for sharing it!

A while back I needed something like this to throttle http requests, and I 
cobbled something together that used Thread/sleep, 
it worked, but vastly inferior to your library, AFAICT. I intent to throw out 
my code out and use your library.

In my application, I would like to have a throttle-fn that was guaranteed not 
to occur faster than some number, but also want to add a (bounded) random 
number to that limit.
For example, let's say I wanted my http requests to be no more frequent than 
every 5 seconds, but some random number of seconds between 5 seconds and 15 
seconds.
Is there any way to add/modify throttler to handle a case like that?

In my application, I use clj-http to make http requests, and what I did was to 
create a wrap-throttle middleware and added that to the middleware stack for the
(customized) http client I used for rate-limited requests.  I am thinking that 
approach would work well with your throttle-fn

Best regards,

Don

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


doall example

2014-05-16 Thread Brian Craft
I came across this today in a library:

results (seq (doall (filter modified? files)))]

I believe the seq is to coerce the empty list to nil. What is the doall for?

Context here:

https://github.com/ibdknox/watchtower/blob/master/src/watchtower/core.clj

-- 
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: doall example

2014-05-16 Thread James Reeves
The doall evaluates all items in the seq, effectively removing any lazy
evaluation. In this case it's necessary because the filter is checking the
modification date of the file, which is obviously mutable.

- James



On 17 May 2014 00:39, Brian Craft  wrote:

> I came across this today in a library:
>
> results (seq (doall (filter modified? files)))]
>
> I believe the seq is to coerce the empty list to nil. What is the doall
> for?
>
> Context here:
>
> https://github.com/ibdknox/watchtower/blob/master/src/watchtower/core.clj
>
> --
> 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.


I'm reading the book "Web Development with Clojure...". On page 4 I entered the command 'leon ring server' and it returns an error message: 'ring' is not a task. See 'lein help'.

2014-05-16 Thread patrick lynch
I'm going thru the book   "Web Development with Clojure...". 
I entered the following commands:

lein new compojure-app guestbook

It ran ok.

I then ran:

> lein ring server

It returned the error message:

'ring' is not a task. See 'lein help'.


Did you mean this?

 run

I'd appreciate any help.
Thank you

-- 
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: I'm reading the book "Web Development with Clojure...". On page 4 I entered the command 'leon ring server' and it returns an error message: 'ring' is not a task. See 'lein help'.

2014-05-16 Thread Gary Trakhman
you have to be inside the guestbook dir.


On Fri, May 16, 2014 at 7:50 PM, patrick lynch wrote:

> I'm going thru the book   "Web Development with Clojure...".
> I entered the following commands:
>
> lein new compojure-app guestbook
>
> It ran ok.
>
> I then ran:
>
> > lein ring server
>
> It returned the error message:
>
> 'ring' is not a task. See 'lein help'.
>
>
> Did you mean this?
>
>  run
>
> I'd appreciate any help.
> Thank you
>
> --
> 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: doall example

2014-05-16 Thread Brian Craft
Ah, thanks. Seems like there's still a race, though. In a long list of 
files, a sequence like

1) doall evaluates modification date of the first file, which is less than 
*last-pass*, so it is filtered out
2) something touches the first file
3) the doall finishes evaluating the rest of the list, after which 
*last-pass* is set to the current time

Now the first file has been updated, but still has modification date less 
than *last-pass*, and will be filtered out of the next pass as well.



On Friday, May 16, 2014 4:50:19 PM UTC-7, James Reeves wrote:
>
> The doall evaluates all items in the seq, effectively removing any lazy 
> evaluation. In this case it's necessary because the filter is checking the 
> modification date of the file, which is obviously mutable.
>
> - James
>
>
>
> On 17 May 2014 00:39, Brian Craft >wrote:
>
>> I came across this today in a library:
>>
>> results (seq (doall (filter modified? files)))]
>>
>> I believe the seq is to coerce the empty list to nil. What is the doall 
>> for?
>>
>> Context here:
>>
>> https://github.com/ibdknox/watchtower/blob/master/src/watchtower/core.clj
>>  
>> -- 
>> 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: Is there a term for non-map collections?

2014-05-16 Thread Jean Niklas L'orange
On Friday, May 16, 2014 6:53:08 PM UTC+2, Mars0i wrote:
>
> Is there a single term that covers vectors, lists, sets, lazy sequences, 
> cons's, etc., but not maps?
>
 
I would use "a collection of keywords" in your example. As mentioned by 
Steve, a map is a collection of map entries/pairs, so a map *cannot* be a 
collection of keywords.

-- Jean Niklas

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


"in Clojure I rarely find myself reaching for something like the state monad, as I would in Haskell"

2014-05-16 Thread Julian
A quick shoutout to the Clojure Community - thanks for the way you've all 
contributed to make my life (mentally) richer. 

James Reeves (author of Compojure and many other wonderful libraries) made 
this interesting comment on Hacker News:
> Clojure has libraries that implement monads, but these aren't often used 
for threading state. I can't quite place my finger on why, but in Clojure I 
rarely find myself reaching for something like the state monad, as I would 
in Haskell.

>Clojure tends to view mutability as a concurrency problem, and the tools 
it provides to deal with mutability, such as atoms, refs, agents, channels 
and so forth, are not mechanisms to avoid mutation, as to provide various 
guarantees that restrict it in some fashion.

>It might be that in the cases where I'd use a state monad in Haskell, in 
Clojure I might instead use an atom. They're in no way equivalent, but they 
have some overlapping use-cases.

https://news.ycombinator.com/item?id=7751424

My question is - have other Clojure/Haskell programmers had this 
experience? (ie "I rarely find myself reaching for something like the state 
monad"). I'm interested to hear if so, and why. 

JG

PS If this post is unhelpful, could be worded better - please let me know. 
I'm asking out of curiosity, not with intent to troll. 

-- 
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: I'm reading the book "Web Development with Clojure...". On page 4 I entered the command 'leon ring server' and it returns an error message: 'ring' is not a task. See 'lein help'.

2014-05-16 Thread patrick lynch
...solved it - if anyone is reading this book - you're going to have to 
change your $PATH in order to get this to work. 
...hope to see you all in the future - if anyone can recommend a Clojure 
User Group in NY/NJ area please let me know.
thanks again

On Friday, May 16, 2014 8:09:30 PM UTC-4, Gary Trakhman wrote:
>
> you have to be inside the guestbook dir.
>
>
> On Fri, May 16, 2014 at 7:50 PM, patrick lynch 
> 
> > wrote:
>
>> I'm going thru the book   "Web Development with Clojure...". 
>> I entered the following commands:
>>
>> lein new compojure-app guestbook
>>
>> It ran ok.
>>
>> I then ran:
>>
>> > lein ring server
>>
>> It returned the error message:
>>
>> 'ring' is not a task. See 'lein help'.
>>
>>
>> Did you mean this?
>>
>>  run
>>
>> I'd appreciate any help.
>> Thank you
>>  
>> -- 
>> 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: Is there a term for non-map collections?

2014-05-16 Thread Mars0i
It's clear that the answer to my question is:
No.  There is no common term for non-map collections.

Btw, the way that I expressed the question has been misleading.  I'm not 
really interested in a function that is supposed to accept only collections 
of keywords.  I defined a function, which in my application will operate on 
collections of keywords, as it happens--in particular, keywords that 
represent things called "persons" in the application.  In the application, 
the argument will always be a vector of person-ids, so I could call it 
"person-vec-to-foo".  On the other hand, since what the function performs 
is a general-purpose operation that could be used for any group of objects, 
I wanted to call it and its parameter something more general.  But it would 
be bizarre to pass maps to the function (unless someone wanted to perform 
operations on MapEntrys) so "collection" seemed like the wrong term.  I 
could give more details or post the code, but I think the answer is clear.  
Thank you to all who answered!

-- 
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: "in Clojure I rarely find myself reaching for something like the state monad, as I would in Haskell"

2014-05-16 Thread Timothy Baldridge
When I first wrote the core.async go macro I based it on the state monad.
It seemed like a good idea; keep everything purely functional. However,
over time I've realized that this actually introduces a lot of incidental
complexity. And let me explain that thought.

What are we concerned about when we use the state monad, we are shunning
mutability. Where do the problems surface with mutability? Mostly around
backtracking (getting old data or getting back to an old state), and
concurrency.

In the go macro transformation, I never need old state, and the transformer
isn't concurrent. So what's the point? Recently I did an experiment that
ripped out the state monad and replaced it with mutable lists and lots of
atoms. The end result was code that was about 1/3rd the size of the
original code, and much more readable.

So more and more, I'm trying to see mutability through those eyes: I should
reach for immutable data first, but if that makes the code less readable
and harder to reason about, why am I using it?

Timothy


On Fri, May 16, 2014 at 6:49 PM, Julian  wrote:

> A quick shoutout to the Clojure Community - thanks for the way you've all
> contributed to make my life (mentally) richer.
>
> James Reeves (author of Compojure and many other wonderful libraries) made
> this interesting comment on Hacker News:
> > Clojure has libraries that implement monads, but these aren't often
> used for threading state. I can't quite place my finger on why, but in
> Clojure I rarely find myself reaching for something like the state monad,
> as I would in Haskell.
>
> >Clojure tends to view mutability as a concurrency problem, and the tools
> it provides to deal with mutability, such as atoms, refs, agents, channels
> and so forth, are not mechanisms to avoid mutation, as to provide various
> guarantees that restrict it in some fashion.
>
> >It might be that in the cases where I'd use a state monad in Haskell, in
> Clojure I might instead use an atom. They're in no way equivalent, but they
> have some overlapping use-cases.
>
> https://news.ycombinator.com/item?id=7751424
>
> My question is - have other Clojure/Haskell programmers had this
> experience? (ie "I rarely find myself reaching for something like the
> state monad"). I'm interested to hear if so, and why.
>
> JG
>
> PS If this post is unhelpful, could be worded better - please let me know.
> I'm asking out of curiosity, not with intent to troll.
>
> --
> 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.
>



-- 
“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 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] Nginx-Clojure v0.2.1 released

2014-05-16 Thread Xfeep Zhang

Nginx-Clojure is a Nginx  module for embedding Clojure 
or Java programs, typically those 
Ring based 
handlers.
The release v0.2.1 has these new features:

   1. Support to close coroutine based socket from non-main thread (issue 
   #19)
   2. Auto generated waving class configurations about Proxy 
   InvocationHandler instance (issue #17 )
   3. Support auto turn on thread pool mode when turning on Run Tool Mode 
   feature (issue #16 )
   4. Fix bug of reading from coroutine based socket inputstream returns 0 
   when eof, should return -1 (issue #15)
   5. Handle multiple sockets parallel in sub coroutines, e.g. we can 
   invoke two remote services at the same time feature (issue #14)
   6. Support nginx rewrite handler to set var before proxy pass (issue #3)
   
More detail please check the Nginx-Clojure github site :

https://github.com/nginx-clojure/nginx-clojure/blob/master/README.md



-- 
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] Throttler: a library for rate limiting

2014-05-16 Thread Bruno Vecchi
I'm glad you're liking Throttler, Don!

As per having a random frequency between an interval, could you clarify a 
bit? Do you want the time between requests to be drawn randomly from some 
distribution each time? If that's the case, the best way I can think of 
would require a change in the implementation of the bucket filling go 
thread. Instead of doing:

(timeout some-constant)

it would have to do

(timeout (sample distribution))

Or maybe even more generally just

(timeout (gen-timeout))

where gen-timeout is just a function that returns a timeout value for the 
next function call. For the common case it would have to be `(constantly 
some-number)`.

If however all you want is to have an upper and a lower bound in the 
throughput, 
you can play with the burstiness value. For the range 1/15 to 1/5 req/s (4 
req/minute to 12 req/minute), your request rate is '(4 :minute) and your 
token number is (12 req/minute - 4 req/minute) * 1 minute = 8. So calling

(throttle-{fn,chan} 4 :minute 8)

would result in your desired average rate and burst rate (with a granularity 
of 1 minute).

I'm curious, what drives this use case of a random throughput?

brunov

On Friday, May 16, 2014 8:31:42 PM UTC-3, dcj wrote:
>
>
> On May 14, 2014, at 9:43 AM, Bruno Vecchi > 
> wrote:
>
> Throttler[1] is a little library I wrote out of need for one of my 
> personal projects. It lets you control the maximum rate of function calls 
> or message transmissions through core.async channels.
>
>
> This is way cool, thanks for sharing it!
>
> A while back I needed something like this to throttle http requests, and I 
> cobbled something together that used Thread/sleep, 
> it worked, but vastly inferior to your library, AFAICT. I intent to throw 
> out my code out and use your library.
>
> In my application, I would like to have a throttle-fn that was guaranteed 
> not to occur faster than some number, but also want to add a (bounded) 
> random number to that limit.
> For example, let’s say I wanted my http requests to be no more frequent 
> than every 5 seconds, but some random number of seconds between 5 seconds 
> and 15 seconds.
> Is there any way to add/modify throttler to handle a case like that?
>
> In my application, I use clj-http to make http requests, and what I did 
> was to create a wrap-throttle middleware and added that to the middleware 
> stack for the
> (customized) http client I used for rate-limited requests.  I am thinking 
> that approach would work well with your throttle-fn….
>
> Best regards,
>
> Don
>

-- 
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] Throttler: a library for rate limiting

2014-05-16 Thread Don Jackson

On May 16, 2014, at 11:11 PM, Bruno Vecchi  wrote:

> As per having a random frequency between an interval, could you clarify a 
> bit? Do you want the time between requests to be drawn randomly from some 
> distribution each time? If that's the case, the best way I can think of would 
> require a change in the implementation of the bucket filling go thread. 
> Instead of doing:
> 
> (timeout some-constant)
> 
> it would have to do
> 
> (timeout (sample distribution))
> 
> Or maybe even more generally just
> 
> (timeout (gen-timeout))
> 
> where gen-timeout is just a function that returns a timeout value for the 
> next function call. For the common case it would have to be `(constantly 
> some-number)`.

I like gen-timeout the best.  It is the most general.  


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