Fork me on GitHub

using, is there a way to execute a sql statement not in a block?

=> (! -db "DISCARD ALL")
PSQLException ERROR: DISCARD ALL cannot run inside a transaction block  org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse (


@wei Use db-do-commands instead of execute! -- then you can tell it to not use a transaction.


( -db false "DISCARD ALL")
assuming -db is the symbol that is bound to your db-spec


(also, if it helps, there's a #sql channel for in-depth JDBC / SQL questions)


@seancorfield perfect-- thanks!


ok I'll ask on #sql for future questions


In general, the assumption is that DDL should be run with db-do-commands and SQL run with query / execute! (and the various insert and delete functions)


I see. for context, this is a workaround to a problem I discovered after upgrading postgres. the most recent version caches prepared statements, so sometimes a migration that changes a table will trigger an error when a cached query is run against that table


PostgreSQL is a strange beast.


is here a replacement to gloss?


or just use gloss even though it’s been archived.


clojure.spec is very useful for taking apart structured data. What is the most similar option for strings? I'd like to put a string into a parser and get a labeled tree out of it.


@jduhamel, we do use gloss in production even though it's been archived and it works fine for us (although it could maybe have more batteries included and nicer exceptions and...). I'm not aware of a replacement.


@miika Thanks. I was not thrilled by a string-based parser declaration when I looked at it. I'll give it a second try.


Oh, it does have PEG, so I can write ordered choices. Sweet.


Search the README for instaparse.combinators - you can declare the parsers with Clojure data as well


Yep, read up to it already. This README is long, and I didn't expect it to have two interfaces 😃


How can I insert record into this table with and postgresql?

CREATE TABLE accounts (
  id serial primary key
I’ve tried these functions.
;; This function call throws PSQLException. It generates invalid query for postgresql.
(! db :accounts {})
;; This works, but cannot get generated ID as return value
(! db ["INSERT INTO accounts (id) VALUES (DEFAULTS);"])


general question about lib deployments to clojars. Is there a best practice for the naming of artifacts? I've seen quite a number of projects deployed without an artifact name prefix, and when there is a prefix, is it considered narcissistic to use your own handle vs some generic grouping or possibly the artifact name itself (`[somename/somename "1.0.0"]`)?. How about the clj- pattern for the project name part of the artifact id? For reference and as two examples of well known clojure libs with both patterns in them, [clj-http "3.8.0"] has no prefix and uses the clj- pattern, whereas [com.rpl/specter "1.1.0"] has a prefix and no clj- pattern.


single-segment artifacts are a bad practice that is being weeded out slowly. using your own handle is fine, but the recommended approach is to use if you own a domain


note that the single-segment clj-http artifact is equivalent to clj-http/clj-http i think


well I own a business which owns a domain and I think this relationship with domains might be fairly common, i.e. devs often live two lives, one in which they work for some entity with a domain, and one where they do open source projects but are possibly not associated with a domain. Ok, well I'll try to refrain from the single-segment pattern then


I assume that goes for the pattern where you use the project name twice as well then...repeating the same string twice doesn't exactly improve the macro behavior of the system


the project name twice is equivalent to the project name once i believe


yeah makes sense...ok I guess I'll meditate over the prefix a bit, need to publish a few libs


using your own handle feels a bit narcissistic though, that would be forcing people to essentially write my name in their project files...a tad intrusive


yeah i'm not a fan of it either


I guess I'm buying a domain then : )


there are those that use their github username and the reverse domain convention like so: com.github.username


I believe that is defined by clojars as a private namespace


ah no that is org.clojars.username not github


then again, if you ever move your project from github to some other place, then that prefix starts to look pretty weird


it seems there is a .ninjadomain ext...`[ "1.0.01"]`?


in fact for this purpose, it would have been good with a domain extension specifically for library publications .lib or something


there is a .dev 😛


would be quite nice to have something like for Clojure i suppose


Hi all, why doesn't this work (map #(% 2 3) '(+ / * -)) but this does? (map #(% 2 3) (list + / * -)) In particular, I'm confused about why the former yields (3 3 3 3)


Nevermind, got it, thanks

mbjarland11:03:47 to enlighten me?


ah they are interpreted as symbols instead of functions


Quoting the list will return a list with the symbols '+ '/ '* '- (list + / * -) will return a list with the vars that are bound to the functions clojure.core/+ etc. Using a backtick instead of a quote will return a list of namespaced symbols that clojure can resolve to be functions, that is:

;; passing `(+ * / -)
(map #(% 2 3) `(+ * / -)) ;;=> (3 3 3 3)


(= '(+ * / -) (list '+ '* '/ '-))
(not= '(+ * / -) `(+ * / -))
(not= `(+ * / -) (list + * / -))
(= (map (comp deref resolve) `(+ * / -))
   (list + * / -))


it worked for me

user> (map #(% 2 3) (list + / * -))
(5 2/3 6 -1)


@tsulej yes, it's the '(+ / * -) version that returns (3 3 3 3), seems + - / * are read as symbols and not as functions


Yeah if you do '() they're symbols not functions


ah, former, sorry


so ('+ 2 3) is trying to look up '+ in 2, failing, and returning default value 3


you can also use juxt for that

user> ((juxt + / * -) 2 3)
[5 2/3 6 -1]


oh neat, thanks


(map #((resolve %) 2 3) '(+ / * -))
=> (5 2/3 6 -1)
also gives the expected result


How would I generate a lazy seq of factorials?


e.g. 1 2 6 24...


Map factorial over range


=> (take 10 (map #(apply * % (range 1 %)) (iterate inc 1)))
(1 2 6 24 120 720 5040 40320 )


Is there a way to do it with corecursion? something like (this doesn't work) (def fact (lazy-cat [1] (map * fact (map inc fact))))



(def fac (lazy-cat [1] (map * fac (rest (range)))))


oo cool, thank you


🙂 @rauh’s solution is special to me because making that work was my first commit to the ClojureScript compiler. There is a cool Fibonacci sequence example like that in


(def fib-seq (lazy-cat [0 1] (map + (rest fib-seq) fib-seq)))


Nice commit message 🙂


Hah! I was more diligent. 🙂


Is the exception shown by *e the complete stacktrace?


@devicesfor you can take the matter into your own hands and avoid whatever any REPL might be doing, by evaluating (.printStackTrace *e)

Drew Verlee15:03:24

I was thinking about starting a “Elements of Clojure” book club. I posted some thoughts here: Feedback and possible participants welcome.


Doesn’t look like you got much response to this, but I’d be quite interested if you do go ahead …

Russ Olsen15:03:32

@devicesfor And of course some code may have caught the original exception and thrown their its own exception, which has the effect of obscuring the original stack trace. Not sure how common this still is in the Java world, but back when I was doing plain old Java it was an all to common thing to do in Java libraries.


I think I might be hitting that case 👍


I need some help interpreting part of the description of agent semantics on - I'd welcome comments here. Here's the quote in question: > The actions of all Agents get interleaved amongst threads in a thread pool. At any point in time, at most one action for each Agent is being executed. Actions dispatched to an agent from another single agent or thread will occur in the order they were sent, potentially interleaved with actions dispatched to the same agent from other sources.


my question is about the last sentence and what it means for actions dispatched from 2 separate sources to be interleaved


I've been assuming that a single action runs until it is finished before yielding to another, regardless of the source


and I'd like it if that second sentence really means that given sources A and B, actions dispatched from both may be executed thus: A1 B1 A2 B2 A3 B3 etc


what I wouldn't like (which would cause me to rethink some things anyway) would be for actions A1 and B1 to be non-atomically interleaved


like A1.1 B1.1 A1.2 B1.2 etc


anyone got the truth to hand? If not, I'll write some kind of experiment later today to figure it out

Alex Miller (Clojure team)16:03:00

actions from send or send-off are enqueued to be applied to an agent and can be interleaved. Each particular send or send-off function runs atomically. There will never be more than one thread applying an action on an agent at one time.


@alexmiller so does that mean that the A1 action (by my understanding, a function) may be partially executed, then paused, and B1 partially executed, paused, and then A1 completed?

Alex Miller (Clojure team)16:03:20

A1 will complete, then B1

Alex Miller (Clojure team)16:03:27

there is no “partial”


excellent, thank you for the clarification


is it true that defn- is considered not a good idea? wondering why if that's the case


In particular, @alexmiller said "At one point all of the current metadata niceties didn't exist (used to be #^{:private true} some may recall) and defn- seemed worth doing I presume (pre-dates my involvementT). But then that was all simplified down to just ^:private and it's preferred to compose the pieces rather than copy N things."


what are people using as a library for very basic data visualization / charting?


was looking at Incanter, but it seems inactive


@krukow Incanter 1.9.2 was released last month. It is true that for a period it saw very little development, but it is usable.


There are a couple libraries that were recently mentioned in the #data-science channel.


I’ll go with incanter


just a simple hobby project


I hit an interesting edge case with logging and macros, overcame it, and blogged about it:

Datomic Platonic23:03:09

the 1.9 command line tools look interesting; we may be able to get rid of boot in some cases, except for the uberjar creation: can you make an uberjar with the clojure tool?

Datomic Platonic23:03:20

@sundarj i've also been pointed to which looks similar