Fork me on GitHub

Hi, I think I need a clarification on when code is executed. I have defined a spec in namespace A, I defined some data in namespace B and am using s/conform to see if it adheres to the spec. Then I use some of the values of namespace B in core. But when I change the spec, I get no errors from the conform statement. Could you shed some light on when code is executed (this is cljs running on shadow-cljs)?


thinking about it, maybe the code is executed, and just returns invalid, and I go on from there. I have to see how to throw errors


is there an existing facility to do that with spec?


Did you re-evaluate namespace A to re-register your changed spec?


I don't recall anything in spec throwing. There are some functions for returning error information however. s/explain will print to *out* while s/explain-data will give you a map with information about the failure, which you could then use to throw an exception, if that is the behaviour you need

Piotr Brzeziński13:01:00

Hello, newbie here 🙂. Is anyone here using intellij (with cursive) for clojure dev? I have a question about it. I have ran a repl for my project by right-clicking on project.clj and I can interact with it just fine. Now when I edit files under src/myproj/core/clj (add a function for example), how do I get that function into the repl? I’m unable to find a proper shortcut combination.

Piotr Brzeziński13:01:11

Ahh, sorry, I was able to find it in the docs in the end.

👍 3

also check out #cursive

Diego Bernardes19:01:58

Hi guys! I’m looking for good references on big projects using a dynamic language like Clojure. Things like refactoring, tests, bugs, etc… I’m starting with Clojure coming from Go and the dynamic thing is kinda of a worry for me.


Discipline, good design, good test coverage, good variable names, documentation on functions and vars, always be using the REPL, that's mostly how


There's some refactoring support in editors, but I consider those "easy" refactors, harder ones where you change things in backward incompatible ways the editor won't do those for you 😛


Getting comfortable with the repl driven development approach should remove most of the concerns you have. It is a relatively small but very significant change to the development workflow. As mentioned, static analysis tools like clj-kondo also give valuable support to the development workflow


you will rely first and foremost on your brain, not on tools, so optimize for that (what didibus said)


I also suggest using some schema lib (clojure spec, plumatic schema or malli) to check and document the format of data at module boundaries


A disadvantage of clojure is that the 'shape' of the data is not always clear. In go/java/haskell etc it's easy to find out which fields the data has (just check the class of datatype definiton)


With clojure you can create a mess where everything is 'just maps' but it's hard to figure out what the fields are. Annotating these with schema, spec of malli at critical points helps a lot to prevent this.


It's not as good as static typing, but it mitigates some of the downsides of the dynamic nature of clojure


@diego.bernardes you may want to have a look at the book "Clojure, Applied", I found it very useful when going from having learned Clojure to needing to build something real world

👍 1
Diego Bernardes19:01:00

I have the Getting Clojure on the way, I’ll take a look on your recommendation too 🙂

Idan Melamed08:01:14

It's from 2015, do you feel it is still relevant?


@UHY8MH6KC apologies for not replying earlier. I dug out my copy and thumbed through, and did not see anything that appears dated. The usefulness will differ from person to person so I'd take a look at the table of contents and see if they are topics that are of use.

👍 1

@diego.bernardes Although it doesn't catch everything, many people, including me, find it useful to enable a linter in the editor and/or in CI: (disclosure: I'm the author of this tool) This can find many "silly" bugs without even running the code. That in combination with a good test suite (which you should have anyway) and good QA practices, should help a lot. Clojure also has clojure.spec and several other data validation/conformation libraries that can help at runtime, but will require you to do extra work (write the specs) if you want more robustness.


There is also editor integration like clojure #lsp (for Calva/VSCode, emacs, ...) and CIDER which can help you find references, rename, etc.

👍 1