Re: Why does `lein new` default to clojure 1.5.1?

2014-05-06 Thread Cecil Westerhof
2014-05-05 22:08 GMT+02:00 mynomoto : > The default lein template has clojure 1.5.1 hardcoded. It will only change > when it's updated there. > ​I was wondering the same also. Would it not be a good idea​ to have the possibility to overrule this? On Monday, May 5, 2014 4:10:38 PM UTC-3, g vim w

CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur

2014-05-06 Thread Roelof Wobben
Hello, I have this form (ns forclojure.core) (defn secondlast [coll counter] (let [ number 0 counter ( - (count coll)2)] (loop [coll counter] (if (== counter number) (first coll) (recur (next coll) (+ counter 1 )) But as soon as I try to

Re: Functional programming and security

2014-05-06 Thread Cecil Westerhof
2014-05-05 12:17 GMT+02:00 Magnus Therning : > On Mon, May 5, 2014 at 10:20 AM, Cecil Westerhof > wrote: > > 2014-05-05 8:21 GMT+02:00 Magnus Therning : > > > >> any language" ;) However, choosing language wisely will allow you to > >> concentrate on solving the 'real' problem at hand, and relie

Re: Functional programming and security

2014-05-06 Thread Cecil Westerhof
2014-05-05 19:48 GMT+02:00 Brian Craft : > I would never have guessed modularity as a reason to worry about security > in fp. > > I worry about immutability in fp, wrt security. Security requires > mutability in order to remove sensitive data from memory, and from app > history. A FIPS > ​Would f

Re: Functional programming and security

2014-05-06 Thread Magnus Therning
On Tue, May 6, 2014 at 9:45 AM, Cecil Westerhof wrote: > 2014-05-05 19:48 GMT+02:00 Brian Craft : >> I would never have guessed modularity as a reason to worry about security >> in fp. >> >> I worry about immutability in fp, wrt security. Security requires >> mutability in order to remove sensitiv

Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur

2014-05-06 Thread Benjamin R. Haskell
`loop` expects a vector of binding forms (with initial values), not just a vector of names. (loop [coll counter]; means there is one `loop` binding named `coll`, with the initial value of `counter` To fix that problem directly: (loop [collcoll ; coll starts with an initial value of

Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur

2014-05-06 Thread Roelof Wobben
Op dinsdag 6 mei 2014 10:43:40 UTC+2 schreef Benjamin R. Haskell: > > `loop` expects a vector of binding forms (with initial values), not just a > vector of names. > > (loop [coll counter]; means there is one `loop` binding named `coll`, > with the initial value of `counter` > > To fix that

Re: Functional programming and security

2014-05-06 Thread Luc Prefontaine
Reading this thread convinced me. I will not write any information on any support except my brain cells and will not share it to avoid any leaks. I will also forget it immediately so no one can scrub my brain to recover it Going to erase everything I wrote and learned in the last past 30 years r

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Phillip Lord
Gregg Reynolds writes: > That sounds about right to me; communication (writing) skills, mainly. Of > course, my degree is in the humanities, so I would say that. Now I think > of computation as a new addition to the classic liberal arts. > > I'm beginning to think that the Clojure documentation

Re: JSON authentication with cemerick/friend?

2014-05-06 Thread Ivan Schuetz
Thanks. I just found out that my middlewares work, I just had to reorder them like this: (def app (-> (handler/api app-routes) (friend/authenticate {:credential-fn (partial creds/bcrypt-credential-fn users) :login-url "/login"

Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur

2014-05-06 Thread Roelof Wobben
I changed everything to this : (ns forclojure.core) (defn secondlast [coll] (let [number 0 ] (loop [coll coll counter (- (count coll)2)] (if (== counter number) (first coll) (recur (next coll) (+ number 1)) But now I get a loop which never ends. Roelo

Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur

2014-05-06 Thread James Reeves
Well, == should be =, but more importantly you're mixing up number and counter. Step through your code one bit at a time: 1. You set number to 0 2. You set counter to (count coll) - 2 3. If number and counter are not equal... 4. Recur with the next part of the list, and set the counter to (+ numb

Re: Converting sequence from sort into a list

2014-05-06 Thread Dave Tenny
In my case I was just trying to ensure a list type for a java API, though perhaps the clojure reflection layer would have converted a non list seq to a list to match the call, I don't know. On Mon, May 5, 2014 at 9:01 PM, Sean Corfield wrote: > My question would be: why do you specifically nee

Re: JSON authentication with cemerick/friend?

2014-05-06 Thread Erik Bakstad
You can also pass inn options to wrap-json-body so you don't have to use keywordize-keys: (def app (wrap-json-body handler {:keywords? true :bigdecimals? true})) kl. 12:04:10 UTC+2 tirsdag 6. mai 2014 skrev Ivan Schuetz følgende: > > Thanks. I just found out that my middlewares work, I just h

Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur

2014-05-06 Thread Roelof Wobben
Op dinsdag 6 mei 2014 12:40:24 UTC+2 schreef James Reeves: > > Well, == should be =, but more importantly you're mixing up number and > counter. > > Step through your code one bit at a time: > > 1. You set number to 0 > 2. You set counter to (count coll) - 2 > 3. If number and counter are not eq

Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur

2014-05-06 Thread James Reeves
You've still got number and counter mixed up. Try going through the loop you've made and writing down their values: 1. coll (list 1 2 3 4 5), number 0, counter 3 2. coll (list 2 3 4 5), number 0, counter 1 3. coll (list 3 4 5), number 0, counter 2 4. coll (list 4 5), number 0, counter 3 5. coll (l

Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur

2014-05-06 Thread Roelof Wobben
As far as I understand recur is going back to the loop so number is never going back to 0 but I see the problem (-(count coll)2 is changing it value and that schould not happen. So I think I have to set the initial value of counter in the let. what schould happen is this coll

Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur

2014-05-06 Thread Roelof Wobben
Found the answer : (defn secondlast [coll] (let [number 0 counter (- (count coll)2) ] (loop [coll coll counter counter number number] (if (= counter number) (first coll) (recur (next coll) counter (+ number 1)) and without the loop there will be

Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur

2014-05-06 Thread Gary Trakhman
Last + butlast? On Tuesday, May 6, 2014, Roelof Wobben wrote: > Found the answer : > > (defn secondlast [coll] > (let [number 0 > counter (- (count coll)2) ] > (loop [coll coll counter counter number number] > (if (= counter number) > (first coll) >

is there a performance test tool by clojure

2014-05-06 Thread Zhi Yang
is there a performance test tool by clojure like scala Gatling -- 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

Re: is there a performance test tool by clojure

2014-05-06 Thread Andrey Antukh
Hi! https://github.com/hugoduncan/criterium this is a good candidate. Greetings Andrey 2014-05-06 15:06 GMT+02:00 Zhi Yang : > is there a performance test tool by clojure like scala Gatling > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. >

Wrapping functions of Java interfaces with inheritance chains

2014-05-06 Thread fs
Disclaimer: I'm new to Clojure programming. I work on some Clojure wrapper functions for a Java API that mainly consists of interfaces. I wonder what the 'usual way of doing things' is regarding inheritance chains. Let's say there's an interface called *Element* that has a *getId()*function. A

Measure HTTP response times

2014-05-06 Thread emptya45
Hi, I am developing a primitive web load test tool using a HTTP client and STM. I wondered if there was a Clojure library I could use that would give me individual HTTP response times? Many Thanks Paul -- You received this message because you are subscribed to the Google Groups "Clojure" g

Re: is there a performance test tool by clojure

2014-05-06 Thread Zhi Yang
thanks, this is mainly for benchmark expression, what I need is a jmeter like app performance tool On Tuesday, May 6, 2014 9:06:11 PM UTC+8, Zhi Yang wrote: > > is there a performance test tool by clojure like scala Gatling > -- You received this message because you are subscribed to the Google

Re: is there a performance test tool by clojure

2014-05-06 Thread François Rey
On 06/05/14 15:32, Zhi Yang wrote: thanks, this is mainly for benchmark expression, what I need is a jmeter like app performance tool In that case: https://github.com/ptaoussanis/timbre -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: is there a performance test tool by clojure

2014-05-06 Thread François Rey
On 06/05/14 15:34, François Rey wrote: On 06/05/14 15:32, Zhi Yang wrote: thanks, this is mainly for benchmark expression, what I need is a jmeter like app performance tool In that case: https://github.com/ptaoussanis/timbre Looking at what Gatling provides in scalaland I guess you may be int

Re: Measure HTTP response times

2014-05-06 Thread François Rey
You may want to check timbre and/or The Grinder , the latter being a full-featured java tool that supports scenario scripting in clojure . -- You received this message because you are subscribed to the Google Grou

Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur

2014-05-06 Thread James Reeves
Yes, except there's no need to pass counter into the loop if it doesn't change. (And naming a constant value "counter" is a little weird). - James On 6 May 2014 13:07, Roelof Wobben wrote: > Found the answer : > > > (defn secondlast [coll] > (let [number 0 > counter (- (count co

Re: Functional programming and security

2014-05-06 Thread Cecil Westerhof
Seriously, when concerns about > security reaches the garbage collector > which operates in live memory, > I wonder why we bother entering > any information in a computer... > ​On a desktop probably not an issue, but on a server that can run for a very long time and has a lot of more hands touchi

Re: CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur

2014-05-06 Thread James Reeves
On 6 May 2014 13:09, Gary Trakhman wrote: > Last + butlast? Yeah, there are a few more concise solutions to this problem if you're familiar with the standard library: (last (butlast coll)) (second (reverse coll)) (peek (pop (vec coll))) And a more efficient loop-solution would just ke

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Gregg Reynolds
On Tue, May 6, 2014 at 4:53 AM, Phillip Lord wrote: > Gregg Reynolds writes: > > That sounds about right to me; communication (writing) skills, mainly. > Of > > course, my degree is in the humanities, so I would say that. Now I think > > of computation as a new addition to the classic liberal a

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Mars0i
On Tuesday, May 6, 2014 4:53:36 AM UTC-5, Phillip Lord wrote: > > Gregg Reynolds > writes: > > That sounds about right to me; communication (writing) skills, mainly. > Of > > course, my degree is in the humanities, so I would say that. Now I > think > > of computation as a new addition to

Re: Wrapping functions of Java interfaces with inheritance chains

2014-05-06 Thread Alex Miller
On Tuesday, May 6, 2014 6:53:51 AM UTC-5, f...@kimchi.io wrote: > > Disclaimer: I'm new to Clojure programming. > Welcome! > I work on some Clojure wrapper functions for a Java API that mainly > consists of interfaces. > > I wonder what the 'usual way of doing things' is regarding inheritance

Re: Clojure On Java Friendly Microcontrollers, Beaglebone, etc

2014-05-06 Thread Jeremy Wright
It's been a long time, but I'm finally getting back to this idea. Starting from the ground up, I've written a blog post on getting Clojure up and running on the BeagleBone Black. In a future blog post I'll circle back around to this discussion, probably attempting to combine the concepts from C

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Mars0i
On Tuesday, May 6, 2014 9:39:47 AM UTC-5, Gregg Reynolds wrote: > > For what it's worth, I generally prefer manpages for API and language > documentation. Very fast, with good search capabilities. > I agree, but I suspect that this is a minority view. > My main complaint about the Clojure d

Re: find the last and the nth item without using last or nth

2014-05-06 Thread Roelof Wobben
I tried this problem again. So I did this: (defn nth* [coll, number] (let [acc 0] (loop [coll coll acc] (if == acc number)) (first coll) (recur (next coll) (+acc 1 )) but when I do : (nth* (1,2,3,4,5)2)) I see a cannot cast error message. Is this because Clojure canno

Re: clojure.zip: skip a node

2014-05-06 Thread Alex Miller
I wrote this article long ago which hints about this at the end: https://www.ibm.com/developerworks/library/j-treevisit/ The approach I have taken for editing trees with zippers is to do a post-walk from end to beginning - that way you're always done transforming and will not walk into your edit

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Phillip Lord
Gregg Reynolds writes: >> I think that the counter argument to that is that many other programming >> languages have a richer documentation system than Clojure, and many >> programmers use them. >> >> To be clear, Clojure's documentation system is an unstructured string, >> the arglists metadata a

Re: find the last and the nth item without using last or nth

2014-05-06 Thread James Reeves
You have a number of typos, syntax errors and missing brackets in your source code. It should be: (defn nth* [coll number] (loop [coll coll, acc 0] (if (= acc number) (first coll) (recur (next coll) (+ acc 1) Additionally, you're using an unquoted list to test. Use a vector

Re: find the last and the nth item without using last or nth

2014-05-06 Thread Roelof Wobben
Thanks, Roelof Op dinsdag 6 mei 2014 17:11:52 UTC+2 schreef James Reeves: > You have a number of typos, syntax errors and missing brackets in your > source code. It should be: > > (defn nth* [coll number] > (loop [coll coll, acc 0] > (if (= acc number) > (first coll) > (recur

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Phillip Lord
Mars0i writes: >> - Add hyperlinks >> - Distinguish between symbols (or names of vars) and normal words. >> - Distinguish between code (examples) and normal words >> - Have access to basic "markdown" style typography. >> >> Less trivial things that I would like to be able to do: >> - tra

Re: clojure.zip: skip a node

2014-05-06 Thread Pascal Germroth
On Tuesday, May 6, 2014 4:07:11 PM UTC+1, Alex Miller wrote: > > I wrote this article long ago which hints about this at the end: > https://www.ibm.com/developerworks/library/j-treevisit/ > I started from that actually, very helpful article. I have since noticed a bug in my previous skip functio

Re: Wrapping functions of Java interfaces with inheritance chains

2014-05-06 Thread fs
Thank you for your in-depth answer! My problem is that in this case, the sub-interfaces are actually very distinct from each other and it would make sense to have separate namespaces for them. So, SubElementA is really very different from SubElementB. Ironically the same API has another inherit

Re: Functional programming and security

2014-05-06 Thread Gary Trakhman
My 'Network Security' Professor once said to the class, 'There is no security without physical security'. Protecting data from being read in memory means you've already lost. On Tue, May 6, 2014 at 5:19 AM, Luc Prefontaine wrote: > Reading this thread convinced me. > I will not write any infor

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Gregg Reynolds
On Tue, May 6, 2014 at 10:11 AM, Phillip Lord wrote: > Gregg Reynolds writes: > >> I think that the counter argument to that is that many other programming > >> languages have a richer documentation system than Clojure, and many > >> programmers use them. > >> > >> To be clear, Clojure's document

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Gregg Reynolds
On Sat, May 3, 2014 at 3:46 PM, Val Waeselynck wrote: > All right, I'll give it a try, here are some thoughts : > > I think it's too hard make precise requirements for advanced features in > advance; I'd rather find a way to let usage drive us in the right > direction. However, there are a few pri

Re: Functional programming and security

2014-05-06 Thread Gregg Reynolds
If you want a friend, get a dog. If you want security, get a big mean-looking dog who barks a lot. Sorry, couldn't resist. On Tue, May 6, 2014 at 11:04 AM, Gary Trakhman wrote: > My 'Network Security' Professor once said to the class, 'There is no > security without physical security'. Prote

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Sean Corfield
On May 6, 2014, at 8:11 AM, Phillip Lord wrote: > I've used this example before; consider this unstructured string from > `cons`. > > Returns a new seq where x is the first element and seq is > the rest. Just because one (or several) of the clojure.core function docstrings are poorly written, d

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Mark Engelberg
On Tue, May 6, 2014 at 9:56 AM, Sean Corfield wrote: > > Returns a new seq where x is the first element and seq is > > the rest. > > Adding complexity and weaving heapings of prose in amongst the code isn't > going to make the developer that wrote the above rewrite it in a better > way. You'll ju

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Tim Daly
> Less trivial things that I would like to be able to do: > - transclude documentation from secondary files, so that the developer >of a piece of code sees a short piece of documentation, while users >of code can see something longer. > - expand the documentation system as I see fit;

Re: http-kit AsyncChannel and clojure.core.async.impl.channels.ManyToManyChannel

2014-05-06 Thread Timothy Baldridge
First of all, this shouldn't work at all, since you aren't requiring core.async, so you shouldn't be getting anything about that library at all. Perhaps you need to reload your repl, or perhaps there's something missing in your gist? Thanks, Timothy On Mon, May 5, 2014 at 3:15 PM, Valentin Luch

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Tim Daly
> Compare Emacs Lisp, for example, which uses semi-structure > in the comments to drive many of its features. Speaking of Emacs, there are (at least) two doc systems available, the emacs "info" system and org-mode. Both of those evolved due to a need for a better documentation system. The claim

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread John Gabriele
On Tuesday, May 6, 2014 1:41:25 PM UTC-4, puzzler wrote: > > On Tue, May 6, 2014 at 9:56 AM, Sean Corfield > > wrote: > >> >> > Sean, I think you missed the point of that example. The point was that > the docstring actually makes sense if it were written as: > > Returns a new seq where `x` is th

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread u1204
> Here's a concrete best-practices suggestion: follow the lead of Haskell and > other functional languages in using x, y, z as generic type names, and x:xs > (where 'xs' is plural of x) to indicate a list of xs; for seqs, maybe > x::xs. So I would rewrite your example to something like: "[x y::ys

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Sean Corfield
On May 6, 2014, at 10:41 AM, Mark Engelberg wrote: > Sean, I think you missed the point of that example. No, I was simply responding to Philip's assertion that the docstring was poorly written. Sean Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ "Perfection is the enemy

Re: clojure.test parameterized tests

2014-05-06 Thread Brian Craft
Using the "testing" macro introduces the same problem with fixtures. Fixtures don't run except around things defined with deftest. Anyone have an example of a test 1) parameterized, and 2) with working fixture? Someone suggested the Expectations lib, but I don't see any fixture support there.

In Lein, is it possible to run a specific test suite?

2014-05-06 Thread Hussein B.
Hi, I'm using clojure.test and Lein. Is it possible to run a specific test suit ? I don't want to run the whole test each time. Thanks for help and time. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@g

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Tim Daly
Gregg, > My original comment on litprog ("bad bad bad") was admittedly a little > strong. I think its bad for some things, fine for others. And it's > possible litprog conventions will evolve to address the problems some of us > see with using it for programming in the large etc. Could you expl

data.xml namespace aware?

2014-05-06 Thread Timothy Washington
Hi there, *A)* I'm just writing some SOAP XML, trying to use data.xml. This SO thread outlines how to write out namespace aware XML. But the example is for a namespace on

Re: In Lein, is it possible to run a specific test suite?

2014-05-06 Thread Alex Miller
Sure! You might try doing "lein help test" to give you a bunch more info about creating custom test sets based on selector tags but you can also Run tests in a namespace: lein test :only my.test.ns Run specific test: lein test :only my.test.ns/test-foo Alex On Tuesday, May 6, 2014 2:22:1

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Tim Daly
> Adding complexity and weaving heapings of prose in amongst the code > isn't going to make the developer that wrote the above rewrite it in a > better way. You'll just end up with more bad documentation getting in > the way of what the code actually does. Bad documentation is worse than > no docum

Re: data.xml namespace aware?

2014-05-06 Thread Timothy Washington
Got a bit further here. I want to be able to get tag namespaces without a :root tag (that includes the namespace definition). Assume the below code has (require '[clojure.data.xml :as xml]). Working with attributes is fine. (def e1 (xml/element :use {:xmlns:xlink "http://testing";,

Re: data.xml namespace aware?

2014-05-06 Thread Timothy Washington
Ok, scratch that. I got it working, lol :) Sorry for the false alarm. For future reference, this: (def e4 (xml/sexp-as-element [:thing:first {:xmlns:thing "http://thing"} [:thing:second {}]])) ...gives you this: user> (process/print-esequel process/e4) http://thing";>

Re: Problem when trying to import SAT4J java class

2014-05-06 Thread Ronan BARZIC
Thank - That fixed the problem - I was using an example from "Clojure Programming" (P 328) and they didn't use square braquets - probably a typo ? Ronan On Mon, May 5, 2014 at 10:50 PM, Jason Felice wrote: > The form should be: > > (:import [org.sat4j.core Vec]) ; note the square braces. >

Immutable or Effectively Immutable?

2014-05-06 Thread Mike Fikes
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 message because you are subscribed to the Google Groups "Clojure" group

Re: Immutable or Effectively Immutable?

2014-05-06 Thread Andy Fingerhut
I haven't read JICP that you refer to, but I believe that they are effectively immutable. See a post by me in this thread titled "Clojure Concurrency and Custom Types" from March 2013 for how to stay within Clojure, but I believe requiring Java interop calls, to mutate in place Clojure's immutable

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Mars0i
On Tuesday, May 6, 2014 2:22:13 PM UTC-5, da...@axiom-developer.org wrote: > > Gregg, > > > My original comment on litprog ("bad bad bad") was admittedly a little > > strong. I think its bad for some things, fine for others. And it's > > possible litprog conventions will evolve to address the

Re: Functional programming and security

2014-05-06 Thread Mars0i
On Monday, May 5, 2014 3:20:41 AM UTC-5, Cecil Westerhof wrote: > > > ​That is why I do not understand that (where I live) they think you can > only be a good programmer if you only program in one language. > If I had to come up with a rule of thumb along this dimension it would be: Any truly ex

Re: http-kit AsyncChannel and clojure.core.async.impl.channels.ManyToManyChannel

2014-05-06 Thread dgrnbrg
The core of the matter is that http-kit's async channels are these: https://github.com/http-kit/http-kit/blob/master/src/java/org/httpkit/server/AsyncChannel.java And core.async's are these: https://github.com/clojure/core.async/blob/master/src/main/clojure/cljs/core/async/impl/channels.cljs#L

Re: Immutable or Effectively Immutable?

2014-05-06 Thread Alex Miller
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/cloj

Re: Immutable or Effectively Immutable?

2014-05-06 Thread Timothy Baldridge
And hash codes are not final as they are calculated on-the-fly on most of the Clojure data structures. Timothy On Tue, May 6, 2014 at 5:49 PM, Alex Miller wrote: > The Clojure persistent data structures are truly immutable - all fields > are final and referred objects are not mutated after con

Re: Immutable or Effectively Immutable?

2014-05-06 Thread Andy Fingerhut
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

Re: clojure.test parameterized tests

2014-05-06 Thread Sean Corfield
http://jayfields.com/expectations/in-context.html On May 6, 2014, at 12:14 PM, Brian Craft wrote: > Someone suggested the Expectations lib, but I don't see any fixture support > there. Anyone using Expectations that can point me to the right place? signature.asc Description: Message signed w

Re: Immutable or Effectively Immutable?

2014-05-06 Thread Michał Marczyk
vec with a short array of objects is a special case in that it simply puts the existing array in a PersistentVector wrapper: user=> (def arr (object-array 16)) #'user/arr user=> (doseq [i (range 16)] (aset arr i i)) nil user=> (def v (vec arr)) #'user/v user=> v [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

Re: Immutable or Effectively Immutable?

2014-05-06 Thread Mike Fikes
Hi Andy, Marking Java fields as final has semantics with respect to threading, defined in the JLS in section 17.5 (http://docs.oracle.com/javase/specs/jls/se5.0/html/memory.html#17.5) If you do this, then it makes it possible to freely pass a "truly" immutable object instance to another thread

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Gregg Reynolds
On Tue, May 6, 2014 at 2:22 PM, Tim Daly wrote: > Gregg, > > > My original comment on litprog ("bad bad bad") was admittedly a little > > strong. I think its bad for some things, fine for others. And it's > > possible litprog conventions will evolve to address the problems some of > us > > see

Re: Immutable or Effectively Immutable?

2014-05-06 Thread Mike Fikes
Thanks! I initially saw that the count field of ArrayNode (in PersistentHashMap) is non-final and also mutated in at least one case, and began to question things. But, for that particular example, if that field is only mutated in the case of editing transients, then for the non-transient case

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread Timothy Baldridge
>> Clojure is being reworked into literate form already Proof of this claim? On Tue, May 6, 2014 at 7:32 PM, Gregg Reynolds wrote: > On Tue, May 6, 2014 at 2:22 PM, Tim Daly wrote: > >> Gregg, >> >> > My original comment on litprog ("bad bad bad") was admittedly a little >> > strong. I thi

Re: Immutable or Effectively Immutable?

2014-05-06 Thread Alex Miller
Yes, there may be a few special cases out there, but largely around transients. The transient case constrains the mutability to a thread so still simplifies the concurrency safety story immensely. On Tuesday, May 6, 2014 8:44:53 PM UTC-5, Mike Fikes wrote: > > Thanks! > > I initially saw that th

Re: Proposing a new Clojure documentation system (in Clojure)

2014-05-06 Thread u1204
Gregg, I realize that literate programming isn't going to catch on in the Clojure community any time soon. LP shared the "epiphany" feature of Lisp. That is, you don't "get it" until the "AH HA!" moment, and then you wonder why anyone programs any other way. You can't get the Lisp AH HA! without w

Re: twitter-api and streaming calls

2014-05-06 Thread Andrew Fitzgerald
I had someone email me today asking for a code snippet of using the java twitter api, so I'll repost it here. I'm fairly new to clojure so forgive me for the ugliness/lack of idiomatic code. It's a port of the java example code at https://github.com/twitter/hbc/blob/master/hbc-example/src/main/j

Re: Immutable or Effectively Immutable?

2014-05-06 Thread Alex Miller
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

Re: Immutable or Effectively Immutable?

2014-05-06 Thread Alex Miller
True! Hash codes are a special case - the pattern they use is sometimes called the "racy single-check idiom" and is discussed in Effective Java in Item 71 or on an internet near you. The canonical example of this is java.lang.String. The trick is that if you don't have a non-0 hash code, comput