Re: ANN Monger 1.1.0-beta1

2012-07-01 Thread Michael Klishin
Bruce Durling escribió: > Excellent news. I look forward to using Monger & friend together. Bruce, I just pushed initial documentation for Ring session stores: http://clojuremongodb.info/articles/integration.html There is nothing specific to Friend but I hope this will be useful to you. I will

Re: Why cannot "last" be fast on vector?

2012-07-01 Thread Vinzent
I fully support Warren's point of view. I'm also unhappy with current behaviour of sequence functions (more accurate: I think it can be made even better). In my mind, protocols (interfaces?) based, polymorphic core functions is just what we need. Moreover, similar request has been done already

Re: Protocol as an abstract data type

2012-07-01 Thread Vinzent
Just an idea: predicate dispatch can be combined with protocols into one thing, eliminating the need for defrecord-like things at all. Low level types defined with deftype, higher-level abstractions defined with that "dynamic protocols" thing. It'd be fun to play with it :) Don't you think the

Re: Protocol as an abstract data type

2012-07-01 Thread David Nolen
How do you think the conditionals can be removed? On Sunday, July 1, 2012, Vinzent wrote: > Just an idea: predicate dispatch can be combined with protocols into one > thing, eliminating the need for defrecord-like things at all. Low level > types defined with deftype, higher-level abstractions de

Re: Protocol as an abstract data type

2012-07-01 Thread Vinzent
Extend on nil, IIndexed and default (I realize that it's currently impossible in cljs). воскресенье, 1 июля 2012 г., 18:39:27 UTC+6 пользователь David Nolen написал: > > How do you think the conditionals can be removed? > > On Sunday, July 1, 2012, Vinzent wrote: > >> Just an idea: predicate dis

cljsbuild 0.2.2 build failure

2012-07-01 Thread Eric Harris-Braun
This gist https://gist.github.com/3019801 shows a lein cljsbuild failure with the error: Could not locate clojure/instant__init.class or clojure/instant.clj on classpath Does anybody have any idea why this would be happening and what to do to fix it? Thanks, -e -- You received this message

Re: Protocol as an abstract data type

2012-07-01 Thread Michał Marczyk
On 1 July 2012 15:04, Vinzent wrote: > Extend on nil, IIndexed and default (I realize that > it's currently impossible in cljs). Actually it is possible and it is how things were originally implemented. The move to the current implementation happened as part of an effort to make things faster. Th

Re: Protocol as an abstract data type

2012-07-01 Thread David Nolen
On Sun, Jul 1, 2012 at 9:04 AM, Vinzent wrote: > Extend on nil, IIndexed and default (I realize that it's currently > impossible in cljs). IIndexed is the protocol that maps to nth. We already extend IIndexed to nil. Extending default to IIndexed leads to horrible things like the following: (ind

Re: Protocol as an abstract data type

2012-07-01 Thread Michał Marczyk
Additionally I would like to note that Haskell's ad hoc polymorphism solution, the system of type classes, allows for extensions predicated on a type class already being implemented: -- no dependencies on other type classes instance SomeClass SomeType where ... -- depend on OtherClass being imp

Re: Protocol as an abstract data type

2012-07-01 Thread David Nolen
On Sun, Jul 1, 2012 at 10:31 AM, Michał Marczyk wrote: > Additionally I would like to note that Haskell's ad hoc polymorphism > solution, the system of type classes, allows for extensions predicated > on a type class already being implemented: > > -- no dependencies on other type classes > instanc

Re: Protocol as an abstract data type

2012-07-01 Thread Michał Marczyk
On 1 July 2012 16:25, David Nolen wrote: > On Sun, Jul 1, 2012 at 9:04 AM, Vinzent wrote: >> Extend on nil, IIndexed and default (I realize that it's currently >> impossible in cljs). > > IIndexed is the protocol that maps to nth. We already extend IIndexed > to nil. Extending default to IIndexed

Re: Protocol as an abstract data type

2012-07-01 Thread Michał Marczyk
On 1 July 2012 16:39, David Nolen wrote: > On Sun, Jul 1, 2012 at 10:31 AM, Michał Marczyk > wrote: >> Additionally I would like to note that Haskell's ad hoc polymorphism >> solution, the system of type classes, allows for extensions predicated >> on a type class already being implemented: >> >>

Re: cljsbuild 0.2.2 build failure

2012-07-01 Thread Daniel Renfer
You need to upgrade to clojure 1.4.0 or later. I don't know if that was by design, but it solved it for me. On Sun, Jul 1, 2012 at 9:52 AM, Eric Harris-Braun wrote: > This gist https://gist.github.com/3019801 shows a lein cljsbuild failure > with the error: > > Could not locate clojure/instant__i

Clojure type of Java array

2012-07-01 Thread Warren Lynn
Somebody asks me to add handling of Java array in clj-cc/last. But I am confused what will be the type of Java array in Clojure. Fox example: (type (.toCharArray "Clojure")) => [C ;; Note: it looks like garbage. but that is what I actually got (isa? (type (.toCharArray "Clojure")) j

ANN "Big Ivan" 0.1.0: BIC/IBAN parser, validator and constructor

2012-07-01 Thread Ben Smith-Mannschott
"Big Ivan" teaches Clojure how to parse, validate and construct BIC and IBAN strings. (BIC and IBAN are both structured identifiers used in banking.) http://github.com/bpsm/big-ivan http://bpsm.github.com/big-ivan/index.html https://clojars.org/org.clojars.bpsm/big-ivan As libraries g

Re: Clojure type of Java array

2012-07-01 Thread David Nolen
If you want to check if something is an array: (.. x getClass isArray) David On Sun, Jul 1, 2012 at 11:35 AM, Warren Lynn wrote: > Somebody asks me to add handling of Java array in clj-cc/last. But I am > confused what will be the type of Java array in Clojure. Fox example: > > (type (.toCharAr

Re: Clojure type of Java array

2012-07-01 Thread Warren Lynn
So if I want to extend a protocol to all Java arrays, is there a single type I can use? Sounds like not. So I need to extend the protocols to char arrays, int arrays and etc? On Sunday, July 1, 2012 12:20:19 PM UTC-4, dennis wrote: > > (type (.toCharArray "Clojure")) is a class, [C means an a

Re: Clojure type of Java array

2012-07-01 Thread David Nolen
The set of Java array types is open. You can however extend array classes as you encounter them at runtime. http://dosync.posterous.com/51626638 David On Sun, Jul 1, 2012 at 1:17 PM, Warren Lynn wrote: > > So if I want to extend a protocol to all Java arrays, is there a single type > I can use?

Re: Why cannot "last" be fast on vector?

2012-07-01 Thread Rich Hickey
Wow, this thread was exhausting :) This reply is not to anyone in particular, just tagging on at the end (hint). It is quite easy to come up to some part of Clojure, with some need, and some current perspective, and find it unsatisfying. It certainly is not perfect. But a good presumption is th

Re: Clojure type of Java array

2012-07-01 Thread Warren Lynn
The idea of dynamic protocol extension on types is very cool. I use that in adding support of Java arrays in 'last'. Thank you. On Sunday, July 1, 2012 1:20:24 PM UTC-4, David Nolen wrote: > > The set of Java array types is open. You can however extend array > classes as you encounter them at ru

'last' on empty collections

2012-07-01 Thread Warren Lynn
Right now (last []) => nil (last [nil]) => nil So there is no way to differentiate these two (except with some emptiness checking). In my opinion (last []) should throw an exception, because that's when last does not apply. From another point of view, there are two cases: 1. The local semantics

Re: 'last' on empty collections

2012-07-01 Thread Jay Fields
It works as I expect, and I would be disappointed if it did throw. Sent from my iPhone On Jul 1, 2012, at 3:47 PM, Warren Lynn wrote: > Right now > > (last []) => nil > (last [nil]) => nil > > So there is no way to differentiate these two (except with some > emptiness checking). In my opinio

Re: 'last' on empty collections

2012-07-01 Thread Dennis Haupt
i'd do (actually, i did) it like this: (my-special-last coll) -> returns the last element or throws an exception if there is none (my-special-last coll if-empty) -> in case of an empty collections, ifEmpty is returned Am 01.07.2012 21:47, schrieb Warren Lynn: > Right now > > (last []) => nil >

Re: Why cannot "last" be fast on vector?

2012-07-01 Thread Warren Lynn
I promised I won't post more on this thread. But Rich is here and I think I can grant myself an excuse to post just one more. End of it, I promise. :-) First, although Rich does not think so, I myself feel this topic is very important as it is not just about "last", It touches some fundamental

Re: 'last' on empty collections

2012-07-01 Thread Softaddicts
Clojure avoid as much as possible making nil or emptiness a special case requiring the caller to test it before calling a function. I would like this to remain like that after years of testing null in Java before doing anything else on a object to prevent exceptions. This is a design decision tak

Re: 'last' on empty collections

2012-07-01 Thread Tyler Perkins
No, I think it's worthwhile to think about a more fundamental semantic. What does nil mean? Although it's often misused, nil is provided so that a function can simply respond, "I can't answer your question". That's the perfect response from (last c) when c is empty, whether c normally contains nil

Re: 'last' on empty collections

2012-07-01 Thread Sean Corfield
On Sun, Jul 1, 2012 at 12:47 PM, Warren Lynn wrote: > Right now > > (last []) => nil > (last [nil]) => nil > > So there is no way to differentiate these two (except with some > emptiness checking). In my opinion (last []) should throw an > exception, because that's when last does not apply. That

Re: 'last' on empty collections

2012-07-01 Thread László Török
Returning nil is consistent across seq functions and play well with when, if-let, when-let, just to name a few... On Jul 2, 2012 12:12 AM, "Sean Corfield" wrote: > On Sun, Jul 1, 2012 at 12:47 PM, Warren Lynn wrote: > > Right now > > > > (last []) => nil > > (last [nil]) => nil > > > > So there

Java 7 & GC Settings

2012-07-01 Thread Bruce Durling
Clojurians, Interesting post here on different GC settings for Java 7. Does anyone have any tips/experience about what settings have worked best for them with clojure and under what circumstances? http://www.fasterj.com/articles/oraclecollectors1.shtml cheers, Bruce -- @otfrom | CTO & co-found

Re: 'last' on empty collections

2012-07-01 Thread Michał Marczyk
On 2 July 2012 00:12, Sean Corfield wrote: > user> (map inc nil) > () > user> (map inc []) > nil Actually that's also (). Agreed on the point of the message. Cheers, M. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send ema

Re: 'last' on empty collections

2012-07-01 Thread Sean Corfield
On Sun, Jul 1, 2012 at 4:18 PM, Michał Marczyk wrote: > On 2 July 2012 00:12, Sean Corfield wrote: >> user> (map inc nil) >> () >> user> (map inc []) >> nil > > Actually that's also (). Agreed on the point of the message. Sorry, copy'n'paste error :) Glad the point was obvious... -- Sean A Corf

Re: 'last' on empty collections

2012-07-01 Thread Warren Lynn
On Sunday, July 1, 2012 4:21:02 PM UTC-4, Dennis Haupt wrote: > > i'd do (actually, i did) it like this: > (my-special-last coll) -> returns the last element or throws an > exception if there is none > (my-special-last coll if-empty) -> in case of an empty collections, > ifEmpty is returned >

Re: 'last' on empty collections

2012-07-01 Thread Warren Lynn
That would be horribly inconsistent with the rest of Clojure, IMO: Sure it will be. That is why I said this is an academic one, and I don't expect any change to current one. > Warren, this and some of your other issues with how Clojure works > makes me curious about your language background.

Re: Clojure type of Java array

2012-07-01 Thread Adam Esterline
Try... (.isArray (type (.toCharArray "Clojure"))) => true On Sunday, July 1, 2012 9:35:38 AM UTC-6, Warren Lynn wrote: > > Somebody asks me to add handling of Java array in clj-cc/last. But I am > confused what will be the type of Java array in Clojure. Fox example: > > (type (.toCharArray "Cloj

File not found exception: instant.clj running: lein cljsbuild

2012-07-01 Thread diego
I am trying to run `lein cljsbuild once` and am getting the exception trace shown at the bottom of this post. I have a Noir/ClojureScript project on OS X 10.7.4, Java 1.6.0_33. My project.clj contains: :dev-dependencies [[lein-cljsbuild "0.2.2"]] :cljsbuild { :source-

Why is map not being lazy here?

2012-07-01 Thread Tim R
i.e. what do I not understand about map and/or promises. (import '(java.util.concurrent Executors)) (def pool (Executors/newFixedThreadPool 10)) (defn sleep-for [t] (. Thread (sleep t)) t) (defn fastest-first-map [f coll] (let [ps (map (fn [_] (promise)) (range (count coll))) a (agent

64 or 32 bit eclipse

2012-07-01 Thread ArturoH
Hello everybody this is my first post. I am new to clojure and Java. Although t i have been programming in other platforms for 15+ years. I started by reading Chad Emerick book. Now i am trying to setup a computer to use for Clojure development environment using eclipse. I had previously downl

Problems With BigDecimal Precision

2012-07-01 Thread Eric Scrivner
Hey All, This is more than likely a newbie question, so my apologies if this is not directly clojure related. I'm not sure if this is a Java or Clojure specific issue, my guess is both. I'm trying to do some probability calculations with both very large and very small numbers. The function I'm

Creating a custom Closure UI component in Clojurescript

2012-07-01 Thread Danny O' Connor
Hello, I'm trying to build an user interface in Clojurescript using the Google Closure library. It appears that the idiomatic way to use the goog.ui package is to create subclasses of goog.ui.Component. Firstly, is this possible in Clojurescript ? This kind of approach doesn't appear to wo

Casting SPELs in Clojure

2012-07-01 Thread Joe Hughes
All, I've been playing with Clojure and found this website, http://www.lisperati.com/clojure-spels/casting.html. Typed the code into Clojure 1.4.0 and got the issue below. Here is the code in question. (defmacro defspel [& rest] `(defmacro ~@rest)) (defspel game-action [command subj obj p

Re: Creating a custom Closure UI component in Clojurescript

2012-07-01 Thread David Nolen
On Fri, Jun 29, 2012 at 9:08 AM, Danny O' Connor wrote: > Hello, > > I'm trying to build an user interface in Clojurescript using the Google > Closure library. > > It appears that the idiomatic way to use the goog.ui package is to create > subclasses of goog.ui.Component. > > Firstly, is this poss

Re: Why is map not being lazy here?

2012-07-01 Thread Stephen Compall
On Sat, 2012-06-30 at 17:46 -0700, Tim R wrote: > i.e. what do I not understand about map and/or promises. That the following test is misdirected. > (chunked-seq? (do-it)) > ;; => false user> (chunked-seq? (map identity (range 5))) false user> (chunked-seq? (seq (map identity (range 5 true

Atom validator ?

2012-07-01 Thread Pierre-Henry Perret
I get an error on a declared CLJS atom when compiled : Uncaught TypeError: Cannot read property 'validator' of undefined But the metadata :validator is not compulsory

Repeatedly asking for user input i.e. calling (read-line) hangs?

2012-07-01 Thread Swaroop
Hi, This might be a naive question, but calling this code causes a "hung" program for me, I would appreciate any suggestions on the right way to do it: user=> (dotimes [n 5] (println "Input:") (read-line)) Input: abc Input: def # /hangs/ Regards, Swaroop -- You received this me