[ANN] defn Podcast Episode #9 Onyx

2016-09-06 Thread Vijay Kiran
Hello Everyone,

The new episode of defn podcast is now available, Onyx with Michael 
Drogalis and Lucas Bradstreet! You can listen to it on SoundCloud[1] or via 
itunes[1]

We'd really appreciate your comments or feedback :)

Enjoy,
Ray & Vijay


[1] https://defn.audio/2016/09/06/episode-9-onyx-with-mike-and-lucas/
[2] https://itunes.apple.com/us/podcast/defn/id1114899563?mt=2

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


Using clojure.spec for api migrations?

2016-09-06 Thread Jeroen van Dijk
Hi,

I'm playing with the idea of using clojure.spec to make an API backwards
compatible by using conform and unform to transform data from the old
version format to a new format version. Below is an example of this in code:

Say we have API change that involves changing the name of a nested key:

(do
  ;; Old api
  (s/def :api.v0.input.nested/label keyword?)
  (s/def :api.v0.input/nested (s/keys :req-un [:api.v0.input.nested/label]))
  (s/def :api.v0/input (s/keys :req-un [:api.v0.input/nested]))

  ;; New api
  (s/def :api.v1.input.nested/key keyword?)
  (s/def :api.v1.input/nested (s/keys :req-un [:api.v1.input.nested/key]))
  (s/def :api.v1/input (s/keys :req-un [:api.v1.input/nested]))

  ;; Migration specs
  (s/def :api.v0-v1.migration.input/nested (s/conformer (fn [_] (throw
(ex-info "Don't use as conformer" {})))
(fn [x]
(clojure.set/rename-keys x {:label :key}

  (s/def :api.v0-v1.migration/input (s/conformer (fn [x]
   (s/conform :api.v1/input
x))
 (fn [x]
   (s/unform (s/keys
:req-un [:api.v0-v1.migration.input/nested]) x

  ;; Changes {:nested {:label :hi}} to {:nested {:key :hi}}
  (s/unform :api.v0-v1.migration/input {:nested {:label :hi}}))

So this kind of works, but I wonder whether there is an easier way or if
I'm thinking about this the wrong way. I was hoping there would be
something like with-unformer (like with-gen) that allows me to change the
unforming action for a specific key without having to copy most of the old
spec.

Any suggestions or advise is appreciated.

Thanks,
Jeroen

-- 
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: How can I evaluate local symbols using eval function in Clojure?

2016-09-06 Thread Beau Fabry
Hi Philos,

Without getting into how to implement this, the `spyscope` library and the 
`clojure.tools.logging` library implement this pattern in their `spy` macro 
and #spy/d reader literal respectively. So you could either add them to 
your development toolkit (recommended) or you could read their 
implementations.

https://github.com/clojure/tools.logging/blob/master/src/main/clojure/clojure/tools/logging.clj#L120
https://github.com/dgrnbrg/spyscope

Cheers,
Beau

On Tuesday, September 6, 2016 at 4:30:09 AM UTC-7, Philos Kim wrote:
>
> I appreciate your reply.
>
> The following is the entire code where I encountered this problem.
> My intention was for debugging purpose to print the result of every nested 
> expression in a form.
>
>
> (ns debux.lab
>   (:require (clojure [walk :as walk])))
>
> ;; For debugging
> (defmacro dbg_
>   [form]
>   `(let [return# ~form]
>  (println ">> dbg_:" (pr-str '~form) "=>" return# "<<")
>  return#))
>
> (def a 2)
> (def b 3)
> (def c 5)
>
> (defn- dispatch
>   [node]
>   (cond
> (list? node)
> (do (eval `(dbg_ ~node))
> node)
>
> (and (symbol? node)
>  (not (fn? (eval `~node
> (do (eval `(dbg_ ~node))
> node)
>
> :else node))
>
> (defn- tree-walk
>   [tree]
>   (walk/postwalk dispatch tree))
>
>
> ;; dbg for nested expressions
> (defmacro dbgn [form]
>   (tree-walk form))
>
>
> ;;; test samples
>
> ;; This works because every symbol is declared in global symbols
> (dbgn (* c (+ a b)))
> ; >> dbg_: c => 5 <<
> ; >> dbg_: a => 2 <<
> ; >> dbg_: b => 3 <<
> ; >> dbg_: (+ a b) => 5 <<
> ; >> dbg_: (* c (+ a b)) => 25 <<
>
>
> ;; This works too, because literal syntax-quotes are used.
> (let [a 10 b 20 c 30]
>   (eval `(* ~c (+ ~a ~b
> ; => 900
>
>
> ;; But this doesn't work, because literal syntax-quotes can't be used in 
> this case.
> (let [a 10 b 20 c 30]
>   (dbgn (* c (+ a b
> ;   2. Unhandled clojure.lang.Compiler$CompilerException
> ;  Error compiling work/philos/debux/src/debux/lab.clj at (52:3)
> ;   
> ;   1. Caused by java.lang.UnsupportedOperationException
> ;  Can't eval locals
> ;   
> ;Compiler.java: 5943 
>  clojure.lang.Compiler$LocalBindingExpr/eval
> ;Compiler.java: 6932  clojure.lang.Compiler/eval
> ;Compiler.java: 6890  clojure.lang.Compiler/eval
> ; core.clj: 3105  clojure.core/eval
> ; core.clj: 3101  clojure.core/eval
> ;..
>
>
> Any suggestion in this case?
>

-- 
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: ClojureScript 1.9.225, cljs.spec fixes

2016-09-06 Thread David Nolen
I just cut 1.9.229. It includes a spec fix as well as a bug around
computing the js dependency index in the presence of .cljc & .cljs files
with the same namespace.

On Fri, Aug 26, 2016 at 6:02 PM, David Nolen  wrote:

> I just cut 1.9.227. The only change was a warning regression around
> cljs.core excludes
>
> David
>
> On Fri, Aug 19, 2016 at 1:40 PM, David Nolen 
> wrote:
>
>> ClojureScript, the Clojure compiler that emits JavaScript source code.
>>
>> README and source code: https://github.com/clojure/clojurescript
>>
>> Leiningen dependency information:
>>
>> [org.clojure/clojurescript "1.9.225"]
>>
>> A bug fix release for cljs.spec and a REPL regression.
>>
>> As always feedback welcome!
>>
>> ## 1.9.225
>>
>> ### Fixes
>> * CLJS-1759: Errors writing transit analysis cache if parallel build
>> * CLJS-1760: Self-host: test-cljs-1757 failing in test-self-parity
>> * CLJS-1751: port fix lost type hints in map destructuring
>> * CLJS-1756: Add test.check JAR to the bootstrap script
>> * CLJS-1757: cljs.spec/exercise-fn doesn't work when passed a quoted
>> symbol
>> * CLJS-1754: Add boolean? generator
>> * fix REPL regression which removed warnings
>>
>>
>

-- 
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: Specter 0.13.0 released

2016-09-06 Thread Nathan Marz
Specter 0.13.0 has been released. Specter is a library that supercharges 
your ability to query and transform regular data structures.
https://github.com/nathanmarz/specter

The new version rewrites the core nearly from scratch to make Specter 
faster and more dynamic. This post gives a detailed explanation of why and 
how Specter's implementation changed: 
https://github.com/nathanmarz/specter/wiki/Specter's-inline-caching-implementation

Also published a benchmark along with the release comparing Specter against 
various manual ways of doing common operations. This includes comparisons 
with lazy operations, transducers, transients, clojure.walk, and other 
miscellaneous functions/interfaces. 
https://gist.github.com/nathanmarz/b7c612b417647db80b9eaab618ff8d83

The full changelog for the release is here: 
https://github.com/nathanmarz/specter/blob/master/CHANGES.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: How can I evaluate local symbols using eval function in Clojure?

2016-09-06 Thread Philos Kim
I appreciate your reply.

The following is the entire code where I encountered this problem.
My intention was for debugging purpose to print the result of every nested 
expression in a form.


(ns debux.lab
  (:require (clojure [walk :as walk])))

;; For debugging
(defmacro dbg_
  [form]
  `(let [return# ~form]
 (println ">> dbg_:" (pr-str '~form) "=>" return# "<<")
 return#))

(def a 2)
(def b 3)
(def c 5)

(defn- dispatch
  [node]
  (cond
(list? node)
(do (eval `(dbg_ ~node))
node)

(and (symbol? node)
 (not (fn? (eval `~node
(do (eval `(dbg_ ~node))
node)

:else node))

(defn- tree-walk
  [tree]
  (walk/postwalk dispatch tree))


;; dbg for nested expressions
(defmacro dbgn [form]
  (tree-walk form))


;;; test samples

;; This works because every symbol is declared in global symbols
(dbgn (* c (+ a b)))
; >> dbg_: c => 5 <<
; >> dbg_: a => 2 <<
; >> dbg_: b => 3 <<
; >> dbg_: (+ a b) => 5 <<
; >> dbg_: (* c (+ a b)) => 25 <<


;; This works too, because literal syntax-quotes are used.
(let [a 10 b 20 c 30]
  (eval `(* ~c (+ ~a ~b
; => 900


;; But this doesn't work, because literal syntax-quotes can't be used in 
this case.
(let [a 10 b 20 c 30]
  (dbgn (* c (+ a b
;   2. Unhandled clojure.lang.Compiler$CompilerException
;  Error compiling work/philos/debux/src/debux/lab.clj at (52:3)
;   
;   1. Caused by java.lang.UnsupportedOperationException
;  Can't eval locals
;   
;Compiler.java: 5943 
 clojure.lang.Compiler$LocalBindingExpr/eval
;Compiler.java: 6932  clojure.lang.Compiler/eval
;Compiler.java: 6890  clojure.lang.Compiler/eval
; core.clj: 3105  clojure.core/eval
; core.clj: 3101  clojure.core/eval
;..


Any suggestion in this case?

-- 
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: How can I evaluate local symbols using eval function in Clojure?

2016-09-06 Thread Philos Kim
I appreciate your reply.

The following is the entire code where I encountered this problem.
My intention was for debugging purpose to print the result of every nested 
expression in a form.


(ns debux.lab
  (:require (clojure [walk :as walk])))

;; For internal debugging
(defmacro ^:private dbg_
  [form]
  `(let [return# ~form]
 (println ">> dbg_:" (pr-str '~form) "=>" return# "<<")
 return#))

(def a 2)
(def b 3)
(def c 5)

(defn- dispatch
  [node]
  (cond
(list? node)
(do (eval `(dbg_ ~node))
node)

(and (symbol? node)
 (not (fn? (eval `~node
(do (eval `(dbg_ ~node))
node)

:else node))

(defn- tree-walk
  [tree]
  (walk/postwalk dispatch tree))


;; dbg for nested expressions
(defmacro dbgn [form]
  (tree-walk form))


;;; test samples

;; This works because every symbol is declared in global symbols
(dbgn (* c (+ a b)))
; >> dbg_: c => 5 <<
; >> dbg_: a => 2 <<
; >> dbg_: b => 3 <<
; >> dbg_: (+ a b) => 5 <<
; >> dbg_: (* c (+ a b)) => 25 <<


;; This works too, because literal syntax-quotes are used.
(let [a 10 b 20 c 30]
  (eval `(* ~c (+ ~a ~b
; => 900


;; But this doesn't work, because literal syntax-quotes can't be used in 
this case.
(let [a 10 b 20 c 30]
  (dbgn (* c (+ a b
;   2. Unhandled clojure.lang.Compiler$CompilerException
;  Error compiling work/philos/debux/src/debux/lab.clj at (52:3)
;   
;   1. Caused by java.lang.UnsupportedOperationException
;  Can't eval locals
;   
;Compiler.java: 5943 
 clojure.lang.Compiler$LocalBindingExpr/eval
;Compiler.java: 6932  clojure.lang.Compiler/eval
;Compiler.java: 6890  clojure.lang.Compiler/eval
; core.clj: 3105  clojure.core/eval
; core.clj: 3101  clojure.core/eval
;..


Any suggestion in this case?

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


Clojure version and quil

2016-09-06 Thread Jerome Manceau
Hi,

I'm very new to Clojure and hitting a wall trying to use quil.

I've created a new project following an example "lein new quil drawing"
It seemed to work but when checking the project.clj I saw that the quil 
dependency was missing.
Also, trying to start a first test application would only throw errors.

Now, I realised that I need clojure version >= 1.7 to have quil working.
But that's where it gets confusing:

- When typing "clojure" in my terminal, I get : Clojure 1.4.0

- When starting "lein repl" and then typing "(clojure-version)", I get: 
"1.2.1"

- When using the REPL on my IDE (NightCode) and typing "(clojure-version), 
I get: "1.9.0-alpha11"

So, how do I upgrade the clojure version in leiningen, so that I can call 
"lein new quil drawing" and get the project created properly?

I'm working on ubuntu 14.4

Thanks for help

-- 
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: How can I evaluate local symbols using eval function in Clojure?

2016-09-06 Thread 'William Parker' via Clojure
Eval expects to get symbols that are resolvable in the current namespace, 
so that won't work (as you mention).  However, in this case it is pretty 
easy to work around.  You just need to embed the values of a and b into the 
code that is evaluated, and since they are primitives this should work. 
 I'd do this like `(+ ~a ~b).  The ` is called "syntax-quote" (you can 
google for that, not that you shouldn't ask questions if something is 
unclear :) ).  Basically you'll get code like (clojure.core/+ 10 20) that 
way; the tilde "~" puts the local values of a and b in the code block 
rather than the symbols a and b.

On Tuesday, September 6, 2016 at 10:41:49 AM UTC+1, Philos Kim wrote:
>
> I need to evaluate local symbols using eval function in Clojure.
>
> (def a 1)
> (def b 2)
>
> (let [a 10
>   b 20]
>   (eval '(+ a b)))
> ;=> 3
>
> I expected the result to be 30, but the result is 3. I want to know why 
> Clojure eval function doesn't evaluate the local symbols.
>
> And any alternative to get around?
>

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


How can I evaluate local symbols using eval function in Clojure?

2016-09-06 Thread Philos Kim
I need to evaluate local symbols using eval function in Clojure.

(def a 1)
(def b 2)

(let [a 10
  b 20]
  (eval '(+ a b)))
;=> 3

I expected the result to be 30, but the result is 3. I want to know why 
Clojure eval function doesn't evaluate the local symbols.

And any alternative to get around?

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


How can I evaluate local symbols using eval function in Clojure?

2016-09-06 Thread Philos Kim
I need to evaluate local symbols using eval function in Clojure.

(def a 1)
(def b 2)

(let [a 10
  b 20]
  (eval '(+ a b)))
;=> 3

I expected the result to be 30, but the reusult is 3. I want to know the 
reason why Clojure eval function doesn't evaluate the local symbols.

And any alternative to get around?

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