This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-12
Channels
- # announcements (2)
- # beginners (104)
- # cider (2)
- # cljs-dev (26)
- # cljsrn (1)
- # clojure (125)
- # clojure-dev (27)
- # clojure-italy (24)
- # clojure-nl (24)
- # clojure-russia (4)
- # clojure-spec (10)
- # clojure-uk (83)
- # clojurescript (18)
- # code-reviews (102)
- # community-development (14)
- # core-async (18)
- # cryogen (11)
- # cursive (15)
- # datomic (16)
- # emacs (6)
- # figwheel-main (6)
- # fulcro (142)
- # graphql (5)
- # jobs (5)
- # jobs-discuss (18)
- # kaocha (1)
- # keechma (1)
- # leiningen (20)
- # luminus (1)
- # mount (5)
- # pedestal (4)
- # reagent (17)
- # reitit (8)
- # shadow-cljs (29)
- # tools-deps (19)
- # vim (108)
As far as query capability is concerned, is there any reason to choose core.logic over datomic for (what I believe) is a constraint logic problem? I'm familiar with both, expert in neither, and I'm trying to figure out when I'd prefer one query model over the other.
Datomic is a whole database, that you need to host and operate or pay for in the cloud. I'd say if all you want is a constraint engine then core.logic is what you want. If you're also looking to persist state, then datomic is what you want.
hi all! I'm a computer engineer and I'm interested in Clojure because of the overtone framework, which seems very good. I'm having troubles in setting up Clojure with Vim. I set up a new project with lein new test
. Then cd test
and lein repl
. I open vim src/test/core.clj
from another terminal. I want to use Repl and auto formatting, but I get "FileNotFoundException Could not locate test/core__init.class or test/core.clj on classpath. clojure.lang.RT.load (RT.java:463)". My (Neo)Vim configuration looks like this.
There is a #vim channel that may be more useful for you. Also there is #beginners
I just met a strange behavior in the Clojure repl: :3d
is accepted as a keyword, but :aoeu/3d
is not. Bug or feature?
RuntimeException Invalid token: :aoeu/3d clojure.lang.Util.runtimeException (Util.java:221)
keywords starting with numeric characters will work, and even (keyword "hello there")
will work, but should be avoided
So the bug looks like :3d
being accepted.
there’s a lot of history on this but we have grand-fathered in keywords that start with a number
is it possible to have multiple implementations of a multimethod for the same dispatch value? ie, i want to catch :foo/bar as a dispatch value in more than one place and handle it differently for each implementation
if that’s not possible, there is nothing stopping you from having a cond
in your multimethod and do more dispatch there, but that kind of defeats the purpose of multimethods
I believe he wants to provide different implementations in different namespaces, such that the "local" or "closest" implementation will be used.
This way, a new namespace could come with its own implementation of a specific method.
its probably buggy because it involves mutable-state, buuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuut
I made a quick test in the repl, and to me it looks like later implementations of the same defmethod would overwrite/shadow earlier definitions.
you can only have one defmethod impl per dispatch value and last one def’ed wins
you don’t need to
all symbols within a syntax quote will (deeply) be resolved to qualified symbols
I figured it out. basically, I’m used to doing
`foo
to get a namespaced variable, but that doesn’t work if you’re already in a syntax quoteright, you actually just need foo
syntax quote resolves all symbols inside it
yes, but in this case the foo
is passed in to the macro as a keyword, which means I have to do something like
`~(name the-keyword)
and I couldn’t figure out the right syntax for that 😄well that isolation doesn’t need to be in syntax quote at all, but I guess you figured that out
yup 🙂 as an intellectual exercise, is it even possible to do this with the right combination of ` and ~?
so I did (symbol (-> *ns* ns-name name) (name method))
outside of the macro and then unquoted that thing instead
as of latest 1.10, you can just call symbol
on a keyword to get the symbol
although that won’t take care of resolving in the current namespace
but resolve
is probably preferable for that
actually, I guess that gets you to a var which is maybe not what you’re looking for
but otherwise you have to reach into the private fields of clojure.lang.Var
Hi, can anybody help me with this? I have a list of maps with this structure:
({:a 1} {:b 2} {:c 3})
How could I get someting like this?
({:a 1 :b 2 :c 3})
What a beauty
I would like to write items to a file one a time from multiple concurrent http requests, and would like to ensure that only one write is made at a time. This would be relatively low volume, but would still like it to be efficient. What's the suggested way to handle this in clojure?
a simple way to do it is a dedicated writer thread and a queue for incoming strings
an agent is a simple way to cover that
@alexmiller is there a good pattern for an agent "owning" an io destination and writing a series of Strings? I think the thing that trips me up is having to pass it a function that returns the new value of the agent which seems clumsy.
just use nil as the value
that is, don’t use one
close over whatever state you need when you make the agent
oh, so just using it for synchronization and not the value itself
nice, I'll have to remember that trick
there are some clojure loggers that do this
I’ve used it for other “single writer” patterns too
your reasoning seems backwards
I like it
what happened to Lacinia channel?
I don’t think there was a separate Lacinia channel, just the #graphql channel
ah, thanks
Tried :main-opts ["-e" "(require 'clojure.test) (clojure.test/run-all-tests)"] but the result is Exception in thread "main" clojure.lang.LispReader$ReaderException: java.lang.RuntimeException: EOF while reading, starting at line 1
Tried :main-opts ["-m" "clojure.main" "-e" "(require 'clojure.test) (clojure.test/run-all-tests)"] but the result is Exception in thread "main" java.lang.NullPointerException at clojure.main$main_opt.invokeStatic(main.clj:317)
you might want to check out https://github.com/cognitect-labs/test-runner (or other tools at https://github.com/clojure/tools.deps.alpha/wiki/Tools)
Whitespace
use ,
instead
:main-opts ["-e" "(require,'clojure.test),(clojure.test/run-all-tests)"]
Because of the way the options are processed by the shell script and written to files and then read back in by the shell script, whitespace breaks things. But because Clojure treats ,
as whitespace, you can work around that issue.
But, yeah, as Alex suggests, look at the Cognitect test runner -- that's how we run everything at World Singles Networks these days.
Oh, the whitespace surprise is issue https://dev.clojure.org/jira/browse/TDEPS-56 .
also, clojure.test isn't going to load your test namespaces, so you'd want to put them in your require or run something that knows how to find and load them
Alright I have a lib and an app that uses the lib; am converting from Leiningen to tools.deps. I used Leiningen "checkouts" to give the app a symlink to the lib so I would not have to constantly mvn install it. Can I do likewise with tools.deps? There is :classpath-overrides but I am puzzled what to set it to. For example, if I say ../lib/src then how will it find the resources?
you could use :override-deps with a {:local/root … } dep instead
Isn't that bugged atm? I recall having to use classpath override to do this a while ago
Oh shoot, I forgot that
someone should fix that
{:deps {my/lib {:mvn/version "1.2.3"}}
:aliases {:dev {:override-deps {my/lib {:local/root "../lib"}}}}}
then clj -A:dev
something like that
I,sympathize,with,but,mentally,suffer,from,some,shell,escaping,escapades.
I often see them as a signal to jump ship out of a shell script and use a "real" programming language.
Yes, clj
and clojure
are right at the boundary between shell and Clojure, and parts of them must live with lowest common denominator I guess.
It isn't clear how I am trying to make an excuse there. bash is what it is, and it isn't going to change fundamentally in the next 10 years, I doubt, nor would I try to.
That sounds to me like you are agreeing you don't like shells as general purpose programming language. If so, we are in violent agreement.
By the way I found your attention to the clojure jira, over the years, very helpful to my understanding.
Cool, glad it helped someone else other than me -- I fear I may have spent more time on that than was mentally healthy for one person to do 🙂
I think I am in progress on that 🙂
I hope your statement above does not mean you feel any need to bow and scrape to me. I certainly don't think there is.
you’re depending on my/lib, but override that artifact to point to a local project
I think I need to declare an alias wholly in /.clojure/deps.edn or wholly in a project's deps.edn; settings within an alias do not merge. For example, I tried putting alias :dev with :override-deps in my /.clojure and alias :dev (same key) with :extra-paths in the project, and the override-deps did not happen.
the merge here is the latter one (and merge replaces)
that is, what you’re saying is correct, aliases do not combine across different deps.edn files, they will be replaced if the same alias is in more than one