This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-18
Channels
- # announcements (6)
- # babashka (16)
- # beginners (194)
- # calva (20)
- # cider (34)
- # clj-kondo (38)
- # clojure (89)
- # clojure-europe (10)
- # clojure-finland (15)
- # clojure-italy (2)
- # clojure-nl (15)
- # clojure-sg (7)
- # clojure-spec (15)
- # clojure-uk (86)
- # clojurebridge (1)
- # clojurescript (60)
- # community-development (11)
- # conjure (13)
- # core-async (48)
- # core-typed (3)
- # cursive (22)
- # datascript (8)
- # datomic (40)
- # duct (11)
- # emacs (3)
- # figwheel-main (22)
- # fulcro (45)
- # graphql (1)
- # helix (9)
- # hoplon (15)
- # hugsql (7)
- # jobs-discuss (47)
- # juxt (7)
- # kaocha (21)
- # luminus (1)
- # malli (13)
- # meander (2)
- # off-topic (52)
- # parinfer (19)
- # re-frame (66)
- # reagent (1)
- # reitit (3)
- # ring-swagger (1)
- # rum (2)
- # shadow-cljs (72)
- # spacemacs (5)
- # sql (4)
- # timbre (5)
- # tools-deps (15)
- # vim (5)
- # vrac (7)
@scott.silver why do you need to call instrument again? I have forgotten how that works.
@scott.silver that's how I do it and I agree it's frustrating.
@drewverlee the problem is that after you eval the buffer all your instrumentation is gone for those functions and does no fdef spec errors will be catched.
Apart from having a custom "eval buffer" function which would call stest/instrument
under the hood I'm not aware of any other solution.
I might ask in #clojure-spec since it's not necessarily specific to cider
thanks @jumar; is it possible to define a custom “eval buffer” function?
Can you replicate this in just a bare clj repl? It’s not clear to me if CIDER is doing something bad or if just instrumentation is a bit sensitive
I don't think it's an issue with cider it's just about improving the workflow when using cider - see follow-up in #clojure-spec : https://clojurians.slack.com/archives/C1B1BB2Q3/p1592451407375900
It's how it works in any repl/tool I believe - the functions you re-evaluate aren't instrumented anymore and you need to call stest/instrument
manually
I don’t use spec, so I can’t provide much input on the subject. I guess the simplest solution would be to avoid eval-buffer after the first time and just re-eval updated expressions. We can also have some eva-buffer-hook
where you can trigger some additional evaluations if needed.
I think problem remains even when you eval a single defn - the instrumented version os gone. But it’s for sure a smaller problem
I think it replaces the function with a wrapper which checks the spec and then calls the original fn
yep @jumar, that’s my understanding, too: https://github.com/clojure/spec.alpha/blob/f23ea614b3cb658cff0044a027cacdd76831edcf/src/main/clojure/clojure/spec/test/alpha.clj#L176
@U051BLM8F I think adding an eval-buffer-hook
would solve this issue; I personally would find it extremely useful.
would that be a difficult feature to add?
It’s pretty simple to add the hook. Please, file some ticket on GitHub so I wouldn’t forget about this.
@jumar I define a collection of all the functions to be instrumented and pass them to the spec instrument
function using a helper function. Then if I evaluate any function definitions I call the helper function and all the functions are instrumented again. If there was a post-eval hook that calls the helper function, then that could be convenient.
For example https://github.com/practicalli/spec-generative-testing/blob/prime/src/practicalli/card_game_specifications.clj#L66-L83
That's interesting but that won't work for me. It's a tedious work to keep this up-to-date and other devs aren't gonna do it 🙂
Oh, sorry to hear about that. Maybe one day you will find a more collaborative dev team to work with :white_frowning_face:
an alternative solution, outside cider, that might be more in keeping with how the creators imagined spec would get it's main utality is you do generative testing of your application. It seems unlikely that clojure wil merge with typed clojure anytime soon so i expect there always to be a friction in doing these sorts of things. If you want to jump that fence part way you can try orchestra though.
@drewverlee what do you mean when you say that Orchestra can get you there part-way?
Has anyone ever wanted to be able to use C-M-x
or C-c C-f
(in other words, the eval defun-at-point
functions) inside a (comment ...)
block?
What I'd like is to keep their normal behavior (evaluating the top-level form you're currently in), but having a exception when the top-form is a comment
, and evaluating the one-before-top-level form.
It's probably a peculiar need.
... as I was looking through cider code to see if I could do it myself, I found a variable that already does it, clojure-toplevel-inside-comment-form
. Not so peculiar after all
I find instrumenting fdef
specifications convenient during development, to help me if I am calling custom functions with incorrect arguments. Switching instrumentation on an off with a helper has been okay for now. I do want to look at using koacha for testing these before pushing code to a shared repo.
https://github.com/jeaye/orchestra looks interesting, but want to get more comfortable with spec before adopting it.
Orchestra is great, but I don’t believe it would alter the requirement that you run (instrument)
after re-evaluating a buffer in the repl.
i think the primary advantage of using Orchestra is that it will check your :ret
and :fn
specs, whereas clojure.spec.test/instrument
will only check the :args
Yes, that makes sense, thank you.
I just noticed Cider is returning Java member docs and eldoc for unresolved symbols without a period, eg. (shift |)
being interpreted as java.lang.StringBuffer/shift
It might be, there was a recent bug fix in the info op and it might have cause that. It is a very balance, do you mind opening in a bug report in orchard
?
I agree we should be prioritizing Clojure vars in the resolution logic. As for the period - keep in mind that references to methods can appear outside the context (.methodName)
- e.g. in (. foo bar)
and (.. foo bar baz)
.
Clojure vars are currently prioritized over Java members, this only seems to happn for unresolved names