Coder Social home page Coder Social logo

Comments (6)

candid82 avatar candid82 commented on August 27, 2024

Interesting, I did not realize -> can be used this way. I do think this is somewhat uncommon and can easily be rewritten with fn, which is only marginally longer but more clear IMO: (map (fn [x] [x]) [1 2 3]). Of course someone who is used to this trick with -> may find fn version less clear, it's all subjective.
Most of the things that Joker catches would be caught otherwise once sent to and ran in REPL. I still find it very useful to be able to catch silly mistakes as early as possible and consider this the core value of Joker's linter mode. So I'd hesitate removing "no forms" check for threading macros. Perhaps it can be made optional. I've initially wanted to keep Joker's config file as small and simple as possible, but looks like more configurable linting rules are necessary in order to satisfy different people's needs...

from joker.

iafilatov avatar iafilatov commented on August 27, 2024

Sure, but it becomes worse with more args:

(map #(-> {:foo %2 :bar %1 :baz %4 :qux %3}) coll)

vs.

(map (fn [a b c d] {:foo b :bar a :baz d :qux c}) coll)

Anyway, this is subjective and not really the point. The point is that in this case linter appears to limit the functionality of the language and the "limitations vs. mistakes caught" ratio is not in its favor (unlike, say, checking for things like (is (= (should-return-false)) false) in tests, e.g. one arg forms of =, >, < ...).

from joker.

rgdelato avatar rgdelato commented on August 27, 2024

I also didn't know that anyone used threading macros this way, though I've occasionally used do to achieve a similar effect. The symbols do and -> even have the same number of characters.
(map #(do [%]) [1 2 3])
(map #(do {:foo %2 :bar %1 :baz %4 :qux %3}) [1] [2] [3] [4])

from joker.

snoe avatar snoe commented on August 27, 2024

Most of the things that Joker catches would be caught otherwise once sent to and ran in REPL.

I've hit bugs where the threaded form updates some stateful thing and the error only crops up at some later point, so I appreciate the linting.

(->> things)
(mapv update-in-db!)

The :rules configuration seems like a natural place to turn off these types of rules.

from joker.

candid82 avatar candid82 commented on August 27, 2024

This is addressed by 5b5375c: you can now turn off linting for this case by setting no-forms-threading rule to false (it's true by default):

{:rules {:no-forms-threading false}}

Thanks @snoe, @rgdelato and @iafilatov for your input.

from joker.

iafilatov avatar iafilatov commented on August 27, 2024

Cool, thanks!

from joker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.