This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-19
Channels
- # announcements (3)
- # babashka (42)
- # beginners (84)
- # calva (3)
- # cider (13)
- # clj-kondo (9)
- # cljs-dev (6)
- # cljsrn (32)
- # clojure (47)
- # clojure-argentina (4)
- # clojure-france (2)
- # clojure-spec (17)
- # clojure-uk (15)
- # clojuredesign-podcast (4)
- # clojurescript (41)
- # conjure (53)
- # cursive (16)
- # data-science (5)
- # duct (1)
- # emacs (11)
- # events (1)
- # exercism (3)
- # fulcro (48)
- # graalvm (20)
- # graphql (1)
- # joker (3)
- # kaocha (2)
- # malli (2)
- # meander (6)
- # pathom (3)
- # planck (18)
- # rdf (3)
- # re-frame (14)
- # ring-swagger (1)
- # shadow-cljs (15)
- # specter (1)
What's a good term for tooling to offer which program to run "a Clojure". ie, lumo, clojure, planck, bb, joker, etc. are these clojures, Clojures, or just a generic "choose a program"?
> ClojureScript is a compiler for Clojure that targets JavaScript. So, a clojure compiler
https://clojure.org/about/clojureclr lists this and clojurescript under "host"
Clojure CLIs? Clojure REPLs?
I wonder if Clojure can be genericized like that. Is there only one Clojure or can many things be a clojure?
I don't think "a Clojure" makes sense. Clojure is a language so that's kind of generic by definition.
It's not like "a Lisp"
clojure (proper) is based on jvm; lumo is based on node.js; plank is based on javascriptcore; babashka is based on graal; joker is, let's say, based on go. so i guess "clojure runtime environment" might be a better choice.
I'm running into some problems with using multimethods in a repl-driven environment. Do they not get reevaluated like regular defs?
I just spent a bit being very confused why some logging wasn't showing up. Bouncing the repl fixed things but I don't want to do that more than once a week : )
@datran if by "they", you're referring to defmulti
s, then the answer is yes (quoting "Clojure Programming", p. 415):
> defmulti
has defonce
semantics, so dispatch functions are not updated simply by reloading a modified defmulti
form. The workaround is to ns-unmap
the multimethod's var--which unfortunately requires reloading each of the multimethod's method implementations as well.
thanks for that! I was going a bit crazy. That's pretty unfortunate, though. I'll have to see if I can incorporate that unmapping in my workflow : /
https://github.com/clojure/tools.namespace solves that and all other sorts of problems that arise with the "reloaded workflow". if you're practicing the "reloaded workflow", you should really be using this library one way or another. 🙂
I am currently using juxt's clip library to handle that, which I thought used tools.namespace internally. I'll have to dig into it now
ok, clip does use clojure.tools.namespace.repl/refresh
, but it doesn't look like that will unmap multimethod Vars
i just created a minimal example to verify that clojure.tools.namespace.repl/refresh
correctly reloads multimethods.
i created a file: fruits.clj
as follows:
(ns fruits)
(defmulti fruit :t)
(defmethod fruit "apple"
[x]
(println "got" x))
(defmethod fruit "banana"
[x]
(println "got" x))
and then, in the same directory, started a REPL as such:
clj -Sdeps '{:deps {org.clojure/tools.namespace {:mvn/version "1.0.0"}} :paths ["."]}'
and here are the steps to verify the behavior:
Clojure 1.10.1
user=> (require '[clojure.tools.namespace.repl :refer [refresh]])
nil
user=> (require '[fruits :refer [fruit]])
nil
user=> (fruit {:type "apple"})
got {:type apple}
nil
user=> (fruit {:type "banana"})
got {:type banana}
nil
;; STOP
;; Here, I switched to another
;; terminal tab where I have
;; `fruits.clj` open in vim and
;; changed the dispatch function for
;; `fruit` from `:type` to `:t`.
user=> (refresh)
:reloading (fruits)
:ok
user=> (fruit {:type "apple"})
Execution error (IllegalArgumentException) at user/eval1696 (REPL:1).
No method in multimethod 'fruit' for dispatch value: null
user=> (fruit {:type "banana"})
Execution error (IllegalArgumentException) at user/eval1698 (REPL:1).
No method in multimethod 'fruit' for dispatch value: null
user=> (fruit {:t "apple"})
got {:t apple}
nil
user=> (fruit {:t "banana"})
got {:t banana}
nil
user=> ^D
i'm not familiar with clip. i use integrant and integrant-repl and haven't had problems with reloading multimethods.
I would like to use Timbre as logging library (I am not very familiar with the java ecosystem, and would like to avoid xml’s), is there any way I can control the logs from the libraries that use tools.logging or java logs using timbre too? Also, if I would write a library, would use timbre for logs cause a headache for users of the library that do not use timbre? If someone has any resource that explains/compares these 2 logging strategies would be great
Expanding a bit, I would like to log maps, not strings (strings would be {:description msg})
At first sight, it seems Timbre would be ideal for “application-level” logging, looks like using https://github.com/fzakaria/slf4j-timbre you can forward almost everything to timbre and from there control the appenders. On the other hand, looks like clojure.tools.logging would be preferred for a library, to let the user of the library decide which backend to use for logging
I am familiar with the Java and SLF4J ecosystem. You are right, libraries should always depend on slf4j-api only and the final app that is using those libraries specify a suitable implementation which will magically receive all the logs from all the libraries. For app level logging as well, I like using slf4j-api because then I can switch the logger implementation at will. You can use Timbre directly, but be aware of the tradeoffs.
@UJRDALZA5 would you mind giving some Timbre tradeoff examples? That's interesting
Sorry, I wasn't clear enough. The tradeoff is, you are tying your code to a specific implementation (Timbre) rather than a facade (interface, SLF4J). I did not mean Timbre itself has some tradeoff, well, there might be, but I am not aware.
What's the name of those vectors where the first item is a keyword representing an operation and the rest are arguments, like in Re-frame? I remember a talk where a specific name was given, but cannot manage to recall it.
Nope, more of a concept in functional programming, something more specific
event, command, mutation are all used commonly
I am fairly sure there is a more sophisticated name, I am looking after that talk but it was years ago I think
Well, "vector variants" to be more precise, I guess
how do I permanently and globally turn off clojure
generating errors reports in /tmp
instead of printing the errors directly?
Full report at:
/tmp/clojure-319502167327667627.edn
I know its done in the spirit of better error messages but this is just worse for me
@thheller I looked this up in main.clj
:
--report target Report uncaught exception to \"file\" (default), \"stderr\",
or \"none\", overrides System property clojure.main.report