This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-13
Channels
- # adventofcode (35)
- # announcements (2)
- # arachne (1)
- # beginners (71)
- # chestnut (2)
- # cider (100)
- # cljdoc (17)
- # cljs-dev (17)
- # cljsjs (2)
- # cljsrn (2)
- # clojure (53)
- # clojure-austin (2)
- # clojure-europe (1)
- # clojure-finland (2)
- # clojure-italy (3)
- # clojure-nl (7)
- # clojure-russia (56)
- # clojure-spec (56)
- # clojure-uk (35)
- # clojurescript (58)
- # community-development (14)
- # core-async (9)
- # cursive (22)
- # data-science (5)
- # datomic (14)
- # duct (5)
- # emacs (2)
- # expound (4)
- # figwheel-main (6)
- # fulcro (23)
- # kaocha (8)
- # lumo (7)
- # off-topic (10)
- # pathom (6)
- # re-frame (17)
- # reitit (31)
- # ring (3)
- # rum (1)
- # shadow-cljs (45)
- # spacemacs (10)
- # sql (12)
- # testing (9)
- # tools-deps (130)
@g0rd0n don’t think so. Have been waiting for someone to take a stab at this. The thing missing is that swagger defines parameters & responses in swagger json schema, while most Clojure web libs use Schema or clojure.spec as the idiomatic way to describe those. Generator would need to convert the params. Just the paths, libs like org.zalando/swagger1st
and metosin/reitit
both use the swagger path format, so the transformation should be quite trivial.
(co-authoring reitit, so happy to help if you would like to do the converter for it)
A question related to the REPL:
I’d like to write a small Clojure program that opens an JSON file and allows me to investigate the content of the JSON as a Clojure object in the REPL.
I was thinking of creating a core.clj
file with a -main
function that receives the path to the JSON file as an argument and define a core.data
var that contains the Clojure representation of the JSON file.
My problem is that I cannot when I pass -m core
to the REPL, it runs the program and exits.
I’d like the REPL to stay open.
Is that feasible?
Yeah. I thought about that but somehow I was expecting to find a simpler solution @dominicm
@dominicm can we have access to command line arguments with -e
?
$ clj -e "(println *command-line-args*)" -m foo 1 2 3
(1 2 3)
@alexmiller awesome This is exactly what I was looking for
And with -r
, I can open a REPL
➜ ~ clj -e "(ns my.aa) (def a 1)" -r
#'my.aa/a
my.aa=> a
1
my.aa=>
Now, I am wondering why -m
is not compatible with -r
?-m starts a program, -r starts a repl
they are different modes
or you can pass a path to run a clj script or - for stdin
-e is an initial option that happens before those (and can be used more than once)
Let's say I have a macro that defines a bunch of local variables for easy of use. Is it possible to conditionally bind them only if they're used in the body?
Is there a built-in clojure function that has the following effect?
(f [] 0) ; => []
(f [1] 0) ; => [1 0]
(f [1 2] 0) ; => [1 0 2 0]
(f [1 2 3] 0) ; => [1 0 2 0 3 0]
Almost interpose
but with the separator also added to the end when the sequence is not empty> added to the end
Does it have to be the last item in the seq, or should it be conj
ed?
I’m trying to figure out how to write a macro that will return a quoted vector of the arguments passed to it
Example
` (quote-me [:user/id])
;;-> ’[:user/id]
any ideas?
=> (doc quote)
-------------------------
quote
(quote form)
Special Form
Yields the unevaluated form.
Please see
Yields the unevaluated form.
@conaw '[:foo]
and [:foo]
are already equal - there's a difference for symbols, the macro you want for that is quote
, which is what '
expands to
also that's not a quoted vector of the arguments, that's taking a vector and returning it
quoting is a compilation time operation that prevents evaluation of literal forms in your source code
it doesn't have a meaning at runtime, unless you are using runtime eval
I might be misunderstanding what you are trying to do here
Sounds like you're asking for an extra level of quote, like (defmacro foo [x]
`(quote (quote ~x)))`
(foo [:user/id]) ==> '[:user/id]
. Like your example.
Oh... looks like I don't know how to put code in slack.
what do you expect
`[~b]
to do that [b]
wouldn't?how would datascript see a difference?
I think it is more because datascript allows things in the pull and query that would otherwise get evaluted
sure, quote those things if you need their unevaluated meaning
and quasiquote can help build a partially quoted data structure with selective evaluation, without needing a macro
right, and you don't actually want a macro for that - you just want a convenient syntax for selective quoting