clj-commons / rewrite-clj

Rewrite Clojure code and edn
https://cljdoc.org/d/rewrite-clj
MIT License
590 stars 55 forks source link

The use of the term "whitespace" can be confusing #144

Open lread opened 3 years ago

lread commented 3 years ago

The zip API has fns:

All good. But... the zip API also has:

While reading code that uses the above functions from the zip API, I get confused.

Perhaps we can clean things up a bit (without breaking the existing API) when we get to #70. If we can't do that we'll stress the oddity in docs.

borkdude commented 3 years ago

Maybe copying those functions to a new name while deprecating the old ones works.

lread commented 3 years ago

Yeah, thanks, I think they will get deprecated, I'll wait and see what new fns #70 introduce here.

Interesting also that we have (skip-whitespace f zloc). Having zloc as the first arg is more the norm in zip API, and more thread-first macro friendly.

mrkam2 commented 6 months ago

I agree that this is confusing. Am I correct that checking for :tag is a safe way to get the exact node type? For example, I want to distinguish spaces and newlines but there doesn't seem to be a function that is checking for that, such as spaces? or newline?.

lread commented 6 months ago

Yes, I don't think we documented :tag as part of the public API, but you can safely use it.

Here's maybe some useful inspiration from cljfmt: https://github.com/weavejester/cljfmt/blob/f3ba8d4d26d3894acdc4875f8b24477c306a3f4b/cljfmt/src/cljfmt/core.cljc#L77-L87

mrkam2 commented 6 months ago

Yes, I don't think we documented :tag as part of the public API, but you can safely use it.

Here's maybe some useful inspiration from cljfmt: https://github.com/weavejester/cljfmt/blob/f3ba8d4d26d3894acdc4875f8b24477c306a3f4b/cljfmt/src/cljfmt/core.cljc#L77-L87

Interesting that they consider comment to be a line break.

lread commented 6 months ago

Interesting that they consider comment to be a line break.

For their purposes, it might make sense: a comment always ends with a line break.