Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lread opened this issue Mar 23, 2021 · 6 comments
Open

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

lread opened this issue Mar 23, 2021 · 6 comments
Labels
hammock requires some thought

Comments

@lread
Copy link
Collaborator

lread commented Mar 23, 2021

The zip API has fns:

  • whitespace? - returns true if Clojure whitespace
  • whitespace-or-comment? - returns true if Clojure whitespace or comment

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

  • skip-whitespace - which skips Clojure whitespace AND comments.
  • skip-whitespace-left - ditto

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.

@lread lread added the hammock requires some thought label Mar 23, 2021
@borkdude
Copy link
Collaborator

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

@lread
Copy link
Collaborator Author

lread commented Mar 23, 2021

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
Copy link

mrkam2 commented Mar 17, 2024

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
Copy link
Collaborator Author

lread commented Mar 17, 2024

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
Copy link

mrkam2 commented Mar 17, 2024

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
Copy link
Collaborator Author

lread commented Mar 17, 2024

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.

@lread lread added this to rewrite-clj Jul 3, 2024
@lread lread moved this to Medium Priority in rewrite-clj Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hammock requires some thought
Projects
Status: Medium Priority
Development

No branches or pull requests

3 participants