Re: ClojureScript def, vars, and binding

2013-01-14 Thread Stuart Campbell
Sorry to dig up such an old thread. I'd also like to maintain the bindings of dynamic vars across asynchronous function calls. Is there a workaround that people use in the absence of bound-fn, etc? Cheers, Stuart On Friday, 27 January 2012 16:49:10 UTC+11, Brandon Bloom wrote: > > The ClojureS

replacing specific symbols in arbitrary expressions

2013-01-14 Thread Jim foo.bar
Hi everyone, I hope you're all well! I recently faced a problem when i needed to receive some piece of code and replace all the invalid symbols in it with the proper (existent) ones. Imagine for example you have the following map from made-up characters to real characters: (def reserved-char

Re: CollReduce and IKVReduce for nil?

2013-01-14 Thread Wolodja Wentland
On Sat, Jan 12, 2013 at 08:15 -0800, Andy Fingerhut wrote: > The CLJ-1098 ticket was categorized as a minor enhancement when it was > created. Defects (i.e. bugs) are considered with higher priority. I can see that this categorisation caused this bug to be prioritised lower than actual bugs that

Re: ClojureScript def, vars, and binding

2013-01-14 Thread David Nolen
There is not. On Monday, January 14, 2013, Stuart Campbell wrote: > Sorry to dig up such an old thread. > > I'd also like to maintain the bindings of dynamic vars across asynchronous > function calls. > > Is there a workaround that people use in the absence of bound-fn, etc? > > Cheers, > Stuart

macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread wujek . srujek
Hi. I am writing a small library (for learning purposes) and there are a few macros. I have a macro that defines some object with the user-specified name and internal some metadata: (defmacro defobj [name operations] ; operations is a map `(def ~name (with-meta ~operations {::my-obj true}))) T

Re: macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread Jim foo.bar
On 14/01/13 14:27, wujek.sru...@gmail.com wrote: (defmacro with-obj [name] (let [obj-meta (meta name)] (if (or (nil? obj-meta)) ; (not (::my-obj obj-meta))) (throw (IllegalArgumentException. (str name " seems not be our object") `(println "nice")) Try this: (defmacro with-obj [

Re: macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread Jim foo.bar
Of course you should know that built-in java types do not support meta-data...You need to implement IObj in order to provide meta-data support to your own types...otherwise use records... Jim On 14/01/13 14:32, Jim foo.bar wrote: On 14/01/13 14:27, wujek.sru...@gmail.com wrote: (defmacro w

Re: macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread Jim foo.bar
Why does this have to be a macro? Why can't it be a first-class function instead? (defn with-obj [ob] (if-let [obj-meta (meta ob)] name (throw (IllegalArgumentException. (str ob " seems not be our object") Jim On 14/01/13 14:34, Jim foo.bar wrote: Of course you should know that buil

Re: macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread Wujek Srujek
Thanks. If I use syntax-quoting, the error will be checked only at the time of executing the (macro-expanded) code, not at macro-expansion time, like some other checks I am performing. Is it possible to achieve what I want while the macro is called? The checks I am performing are some semantic chec

Re: macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread Wujek Srujek
Because this is not the whole functionality ;d The check is just a fragment, the one that doesn't work. There is much more to it, like taking the object, taking some keys and values and using them in (let) and then executing some code in this context (which is another parameter, which is not in my

Re: macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread Wujek Srujek
Actually, the with-object mecro is very similar to clojure.algo.monads/with-monad - it also lets a few bindings, like m-bind or m-result, and executes user-defined expressions in the context of the monad specified by a name. They just don't perform such checks, you can call with-monad with any symb

[ANN] modern-cljs tutorial-10 - Introducing Ajax

2013-01-14 Thread Giacomo Cosenza
Hello everybody, I just published the la last (10th) tutorial of modern-cljs series. It introduces ajax model in CLJS. It uses domina, hiccups and shoreleave-remote on the client side; ring, compojure, shoreleave-remote-ring on the server-side. https://github.com/magomimmo/modern-cljs/blob/mas

How do I install guice?

2013-01-14 Thread larry google groups
I am building a web app. I just included Compojure and Friend as dependencies, and one of these, in turn, relies on Google Guice. I type: lein uberjar and I get a whole lot of output which includes: Could not find artifact com.google.code.guice:guice:pom:2.0 in central (http://repo1.maven.org/ma

Re: macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread Jim foo.bar
I am not sure I follow...Do you by any chance want the macro-expansion to lead you directly to one of your two options (printing or exception)? In this case you can do this: (defmacro with-obj [ob] (if-let [obj-meta (meta ob)] (eval ob) ;not replacing any code but eval-ing on the fly (thro

Re: macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread Wujek Srujek
When I invoke a macro: (with-object someobject) someobject is not evaluated, it is passed as a symbol to the macro. I need somehow to get the meta for the object that is hidden behind that symbol. So, I won't be passing objects in-line, as you did in your Foo example, I will first be doing: (defobj

Re: How do I install guice?

2013-01-14 Thread Chas Emerick
Please change your Friend dependency to [com.cemerick/friend "0.1.3"]. Prior versions transitively depended upon a Guice artifact that was hosted on a now-404 Maven repository via Google Code's svn. Friend >= 0.1.3 depends only on artifacts available in Clojars and Maven Central, and will remai

Re: macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread Jim foo.bar
aaa ok now I understand what you meanI'm really sorry but I hadn't read all your original questions. So lets set things straight: 1. should I attach the meta to the object, or to its var? or maybe I shouldn't do it at all, and just omit such checks altogether? (but I would still like to kn

Re: How do I install guice?

2013-01-14 Thread larry google groups
Thank you for the fast reply. That helped. But do you (or anyone else here) know of a workaround for friend-oauth2? I get: lein uberjar Could not find artifact friend-oauth2:friend-oauth2:pom:0.0.2 in central (http://repo1.maven.org/maven2) Retrieving friend-oauth2/friend-oauth2/0.0.2/friend-oauth

Re: CollReduce and IKVReduce for nil?

2013-01-14 Thread Peter Taoussanis
Just throwing in here that I was actually bit by IKVReduce just today. I swapped a reduce with a reduce-kv, assuming the two would function similarly. And, unfortunately, they did in the testing environment: it took a trip to production before a nil came up. The current behavior is certainly un

Re: How do I install guice?

2013-01-14 Thread Chas Emerick
Instead of this: [friend-oauth2 "0.0.2"] Use this: [friend-oauth2 "0.0.2" :exclusions [com.cemerick/friend]] [com.cemerick/friend "0.1.3"] That will keep lein from attempting to resolve the now-gone Guice artifact transitively referred to by the older revs of friend. - Chas On Ja

pool-map - a more disciplined version of pmap on top of executors

2013-01-14 Thread Jim - FooBar();
First of al let me say that pmap is NOT useless at all...I've encountered cases where I've had to accumulate a collection of 'pmap'-ed elements (say Strings) before the final task (say 'spit'-ing them) where having laziness is a big win in terms of memory footprint...On the other hand there are

Re: macro: retrieving metadata for an object bound to a symbol passed as argument

2013-01-14 Thread Wujek Srujek
Hi. Yes, the (eval `(meta ~name)) did the trick, it also seems to be working the way I would like it to in terms of namespaces, which is great! I must confess that I don't fully grok why it has to be that way (syntax-quote plus syntax escape plus eval), but I will just have learn more and hopefully

Re: replacing specific symbols in arbitrary expressions

2013-01-14 Thread Alan Malloy
(clojure.tools.macro/symbol-macrolet [P +, M -, T *] ...) The tools.macro code-walker is much smarter and more careful than any that you or I will ever write. On Monday, January 14, 2013 3:31:40 AM UTC-8, Jim foo.bar wrote: > > Hi everyone, I hope you're all well! > > I recently faced a probl

Re: pool-map - a more disciplined version of pmap on top of executors

2013-01-14 Thread Marko Topolnik
> (defn pool-map > "A saner, more disciplined version of pmap. Not lazy at all. > Don't use if original ordering of 'coll' matters!" > [f coll] > (let [cpus (.. Runtime getRuntime availableProcessors) >exec (Executors/newFixedThreadPool cpus) >pool (ExecutorCompletionService.

Re: ANN: bouncer, validation library for clojure

2013-01-14 Thread Gary Johnson
Hey Leonardo, There's a critical bug in 0.2.2-RC1 in the bouncers.core/wrap function. An IllegalArgumentException is triggered whenever a validator is not passed an explicit :message field. It looks like this was introduced in the process of trying to allow validators to take an arbitrary num

[ANN] nrepl-transcript

2013-01-14 Thread Jonas
Hi I created a middleware for nrepl that saves a transcript of your repl interactions so you can go back and see what you did. https://github.com/jonase/nrepl-transcript Feedback welcome! Jonas -- You received this message because you are subscribed to the Google Groups "Clojure" group. To

Re: pool-map - a more disciplined version of pmap on top of executors

2013-01-14 Thread Jim - FooBar();
On 14/01/13 20:47, Marko Topolnik wrote: What exactly is the value provided by ExecutorCompletionService? To my eyes, this function is quite similar to (comp doall pmap), but with shuffled result. There is no advantage to using the lazy approach to submitting tasks: you could have simply used i

Re: pool-map - a more disciplined version of pmap on top of executors

2013-01-14 Thread Jim - FooBar();
On 14/01/13 21:27, Jim - FooBar(); wrote: On 14/01/13 20:47, Marko Topolnik wrote: What exactly is the value provided by ExecutorCompletionService? To my eyes, this function is quite similar to (comp doall pmap), but with shuffled result. There is no advantage to using the lazy approach to sub

Re: replacing specific symbols in arbitrary expressions

2013-01-14 Thread Jim - FooBar();
wow! this looks very useful... thanks Alan - knowledgeable as always! :-) Jim On 14/01/13 19:41, Alan Malloy wrote: (clojure.tools.macro/symbol-macrolet [P +, M -, T *] ...) The tools.macro code-walker is much smarter and more careful than any that you or I will ever write. On Monday, Jan

Re: pool-map - a more disciplined version of pmap on top of executors

2013-01-14 Thread Marko Topolnik
But... you were quite clear in stating that your function isn't lazy, and you were right to say that: *doall* will not return until *all* the tasks have completed. Maybe you did want laziness, after all? On Monday, January 14, 2013 10:27:18 PM UTC+1, Jim foo.bar wrote: > > I think the advantage

Re: pool-map - a more disciplined version of pmap on top of executors

2013-01-14 Thread Marko Topolnik
Yet another issue with your function is that it doesn't submit all the tasks up front so it clearly won't prevent longer tasks from delaying the shorter ones. But, even if they are submitted all at once, like in my version, the executor service will still enqueue them internally, with the same

Re: ANN: bouncer, validation library for clojure

2013-01-14 Thread Leonardo Borges
Hi Gary, Thanks for the bug report. Which version of Clojure causes the issue? I've been using Clojure 1.4 and the exact snippet you posted works flawlessly. As well as bouncer, given I have test cases around validators with no explicit messages. Cheers, Leonardo Borges www.leonardoborges.com

Re: pool-map - a more disciplined version of pmap on top of executors

2013-01-14 Thread Jim - FooBar();
On 14/01/13 22:15, Marko Topolnik wrote: But... you were quite clear in stating that your function isn't lazy, and you were right to say that: /doall/ will not return until *all* the tasks have completed. Maybe you did want laziness, after all? I'm not entirely sure what you mean here...The on

Re: ANN: bouncer, validation library for clojure

2013-01-14 Thread Leonardo Borges
Alright so the bug appears in Clojure 1.5.0-RC1 - I'm not sure whether this is a regression or intended behaviour so I'll send a separate email to the list about that. In the meantime I've applied a fix and pushed [bouncer "0.2.2-RC2"] With this change I'm also using lein profiles to run the test

map destructuring mismatch between Clojure 1.4.0 and 1.5.0-RC1

2013-01-14 Thread Leonardo Borges
Hi all, A user reported a bug in my library and after tracking it down it turned our to only happen on Clojure 1.5.0-RC1. Here's the behaviour in 1.4.0: (let [{:keys [message] :or {message "foo"}} '()] message) ;; "foo" And here's what happens in 1.5.0-RC1: (let [{:keys [message] :or {message

Re: map destructuring mismatch between Clojure 1.4.0 and 1.5.0-RC1

2013-01-14 Thread Sean Corfield
See http://dev.clojure.org/jira/browse/CLJ-1140 On Mon, Jan 14, 2013 at 3:57 PM, Leonardo Borges wrote: > Hi all, > > A user reported a bug in my library and after tracking it down it turned our > to only happen on Clojure 1.5.0-RC1. > > Here's the behaviour in 1.4.0: > > (let [{:keys [message] :

Re: map destructuring mismatch between Clojure 1.4.0 and 1.5.0-RC1

2013-01-14 Thread Leonardo Borges
Thanks! Leonardo Borges www.leonardoborges.com On Tue, Jan 15, 2013 at 11:08 AM, Sean Corfield wrote: > See http://dev.clojure.org/jira/browse/CLJ-1140 > > On Mon, Jan 14, 2013 at 3:57 PM, Leonardo Borges > wrote: > > Hi all, > > > > A user reported a bug in my library and after tracking it do

Re: ANN: bouncer, validation library for clojure

2013-01-14 Thread Toby Crawley
This issue has already been reported and filed: http://dev.clojure.org/jira/browse/CLJ-1140 There's been some discussion around that issue on clojure-dev@ as to whether this is a regression or an abuse of destructuring. Leonardo Borges writes: > Alright so the bug appears in Clojure 1.5.0-RC1 -

Re: ANN: bouncer, validation library for clojure

2013-01-14 Thread Leonardo Borges
Sean pointed me to it in the other thread. I read the ticket and discussion - I personally don't feel it's abuse. To me it feels as natural a use of destructuring as any other. just my 2c. Leonardo Borges www.leonardoborges.com On Tue, Jan 15, 2013 at 11:14 AM, Toby Crawley wrote: > This issu

[ANN] Immutant 0.8.0 released

2013-01-14 Thread Jim Crossley
We released Immutant 0.8.0 today, which includes our new Pipelines library, persistent caches, and some minor features relating to web apps and testing. We didn't break any API's from 0.7.0, so hey, progress! More details at http://immutant.org/news/2013/01/14/announcing-0-8-0/ # What is Immuta

Re: [ANN] nrepl-transcript

2013-01-14 Thread Colin Jones
Great idea - and with so little code! On Monday, January 14, 2013 2:58:55 PM UTC-6, Jonas wrote: > > Hi > > I created a middleware for nrepl that saves a transcript of your repl > interactions so you can go back and see what you did. > > https://github.com/jonase/nrepl-transcript > > Feedback w

Re: Better ways of documenting functions with type information?

2013-01-14 Thread u1204
Try literate programming. If you are going to write a program it will be read many times. Try to write as though you were writing a book. Make the code be just a "reduction to practice" of the words in the book. The idea of literate programming is that you write for other people and, incidentally,

Standardized value for "no-value"?

2013-01-14 Thread Frank Siebenlist
I'm using those watcher-fns that get called when the watched ref changes, and the watcher-fn gets passed the old-value and the new-value. Now, nil is a proper value for a key-value and well as a val-value in a map, so passing nil does not give you the info whether or not an old-value existed or

Re: Standardized value for "no-value"?

2013-01-14 Thread Timothy Baldridge
It's fairly common in situations like this to use a namespaced keyword. For instance ::unknown (which is short for my.namespace/unknown). On Mon, Jan 14, 2013 at 6:06 PM, Frank Siebenlist < frank.siebenl...@gmail.com> wrote: > I'm using those watcher-fns that get called when the watched ref chan

a join function that can be used in a reduce

2013-01-14 Thread Andrew Xue
Hi -- Building some generic joining functionality on top of cascalog, the clojure package for big data. I have a join function that is defined like this: (defn join [lhs rhs join-ons] ..implementation ...) lhs and rhs are subqueries. the join returns then another query that is a join of the

Re: Standardized value for "no-value"?

2013-01-14 Thread Frank Siebenlist
Understood. … but shouldn't it be a standardized constant for the whole community to use to avoid any interoperability issues and many reinvented wheels? The concept of no-value versus nil is a pretty basic one - there must be better solutions (re)invented many times over ;-) -FS. On Jan 14,

Re: Standardized value for "no-value"?

2013-01-14 Thread Frank Siebenlist
For clojure I came up with the following alternative using an unbound var: user=> (def v) #'user/v user=> (defn f [x] (if (var? x) (if (bound? x) x :no-value) x)) #'user/f user=> (f v) # user=> (f #'v) :no-value user=> (f #'map) #'clojure.core/map user=> (type (f v)) clojure.lang.Var$Unbound user=

Re: Standardized value for "no-value"?

2013-01-14 Thread Frank Siebenlist
Ok - ClojureScript has an undefined? function that works like: ClojureScript:cljs.user> (def v) ClojureScript:cljs.user> (undefined? v) true ClojureScript:cljs.user> (def w nil) nil ClojureScript:cljs.user> (undefined? w) false ClojureScript:cljs.user> (defn f [v] (if (undefined? v) :no-value v)

CLJS: undefined and nil are "equally" nil?

2013-01-14 Thread Frank Siebenlist
ClojureScript:cljs.user> (def a nil) nil ClojureScript:cljs.user> (def b) ClojureScript:cljs.user> (undefined? a) false ClojureScript:cljs.user> (undefined? b) true ClojureScript:cljs.user> (nil? a) true ClojureScript:cljs.user> (nil? b) true ClojureScript:cljs.user> (type a) nil ClojureScript:clj

Re: CLJS: undefined and nil are "equally" nil?

2013-01-14 Thread David Nolen
This behavior is desirable. Unless you are in some dark cave of interop you shouldn't care. On Tuesday, January 15, 2013, Frank Siebenlist wrote: > ClojureScript:cljs.user> (def a nil) > nil > ClojureScript:cljs.user> (def b) > > ClojureScript:cljs.user> (undefined? a) > false > ClojureScript:clj

Re: CLJS: undefined and nil are "equally" nil?

2013-01-14 Thread Frank Siebenlist
ClojureScript:cljs.user> (def a nil) nil ClojureScript:cljs.user> (def b) ClojureScript:cljs.user> (= a b) true user=> (def a nil) #'user/a user=> (def b) #'user/b user=> (= a b) false I didn't realize that the above is dark cave material ;-) Could you elaborate a little on the

Re: Full stack Clojure web/REST framework - is there any mileage in it?

2013-01-14 Thread Michael Bonar
I've been giving a lot of thought to frameworks and tempates lately, so I'll share my thoughts. The goal of frameworks and templates, in my mind, is repeatable assembly. Small, focused libraries don't get in the way of that design goal. Frameworks and templates sit on top of the language. W

[ANN] matsu - SPARQL query DSL

2013-01-14 Thread Petter Goksøyr Åsen
Matsu is a DSL for constructing SPARQL queries: (query (select :person) (where :person a [:foaf "Person"] \; [:foaf "mbox"] (URI. "mailto:m...@me.com";) \.)) Which would yield the following string (but not formatted with tabs & newlines): PREFIX foaf:

Re: Full stack Clojure web/REST framework - is there any mileage in it?

2013-01-14 Thread Michael Bonar
Let me add a couple more thoughts. I hung out on the TurboGears project a few years ago because I thought they were heading in a good direction. They use templating engines (Genshi), and I like that idea. One framework; many templates. They also made a major redesign decision mid stream, so

Re: CLJS: undefined and nil are "equally" nil?

2013-01-14 Thread Jordan Berg
I find this to be useful: cljs.user> (nil? (.-key (js-obj))) true I like not having to use undefined? for this On Tue, Jan 15, 2013 at 1:08 AM, Frank Siebenlist < frank.siebenl...@gmail.com> wrote: > ClojureScript:cljs.user> (def a nil) > nil > ClojureScript:cljs.user> (def b) > > ClojureScrip