Skip to content

Automated Resyntax fixes #461

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Automated Resyntax fixes #461

wants to merge 9 commits into from

Conversation

resyntax-ci[bot]
Copy link
Contributor

@resyntax-ci resyntax-ci bot commented Nov 27, 2024

Resyntax fixed 20 issues in 10 files.

  • Fixed 9 occurrences of tidy-require
  • Fixed 3 occurrences of map-to-for
  • Fixed 2 occurrences of if-begin-to-cond
  • Fixed 1 occurrence of if-let-to-cond
  • Fixed 1 occurrence of ormap-to-for/or
  • Fixed 1 occurrence of cond-let-to-cond-define
  • Fixed 1 occurrence of when-expression-in-for-loop-to-when-keyword
  • Fixed 1 occurrence of let-to-define
  • Fixed 1 occurrence of define-syntax-syntax-rules-to-define-syntax-rule

Keep imports in `require` sorted and grouped by phase, with collections before files.
Internal definitions are recommended instead of `let` expressions, to reduce nesting.
This `map` operation can be replaced with a `for/list` loop.
This `define-syntax` macro can be replaced with a simpler, equivalent `define-syntax-rule` macro.
`cond` with internal definitions is preferred over `if` with `let`, to reduce nesting
Internal definitions are recommended instead of `let` expressions, to reduce nesting.
This `ormap` operation can be replaced with a `for/or` loop.
Using `cond` instead of `if` here makes `begin` unnecessary
Use the `#:when` keyword instead of `when` to reduce loop body indentation.
(and (pair? p) (equal? (car p) (car r)) (loop (cdr r) (cdr p)))
(case mode
[(get-path)
`(,(cadr root+url+flags) ,@p
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackfirth I'd rather see

(append (list (cadr root+url+flags)) 
        p 
        (list (if ...)))

here.

In general, I think quasiquote should only be preserved if there exists an item that is not unquote / unquote-splicing. If all of them are unquote / unquote-splicing, either it should be converted to a list or an append.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use a different rule for this. If I'm thinking of it as an sexpression, I'd use quasiquote and friends; if I'm thinking of it as a list, I'd use append and friends.

So maybe the quasiquote should be preserved by the tool and a user should make this judgment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's pretty fuzzy in a lot of cases, so Resyntax is conservative and only takes a hard stance on the cases that seem clearly absurd to me like this:

`(,a ,b ,c)
; just write `(list ...)` man, you're not fooling anyone

In the code you commented on, I would also prefer to avoid quotation for the same reason as you. But I dislike datum quotations generally and that's a much stronger stance than many Racketeers. So I don't think Resyntax should actively discourage it.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants