Skip to content

Add a space in complex anonymous functions#236

Merged
DavisVaughan merged 5 commits intomainfrom
feature/unary-formula
Feb 20, 2025
Merged

Add a space in complex anonymous functions#236
DavisVaughan merged 5 commits intomainfrom
feature/unary-formula

Conversation

@DavisVaughan
Copy link
Collaborator

Closes #235

Copy link
Collaborator

@lionel- lionel- left a comment

Choose a reason for hiding this comment

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

Do we have tests for chained unary formulas?

It should look like:

~~foo
~~ 1 + 2

Comment on lines 48 to 50
// "Complex" is anything except identifiers
!matches!(argument, AnyRExpression::RIdentifier(_))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would expect ~NA and ~NULL to be treated like ~foo?
And probably other literals like ~10 too?

Copy link
Collaborator Author

@DavisVaughan DavisVaughan Feb 20, 2025

Choose a reason for hiding this comment

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

I don't think so, I believe that this behavior is only for identifiers. And is somewhat special to supporting tribble calls

tribble(
  ~x, ~y,
  ...
)

If not for tribble I would have been happy with unconditionally using a space between the ~ and the rhs, so to me the ~foo behavior is just a surgical patch to help that, and everything else gets a space

@DavisVaughan DavisVaughan merged commit 207f569 into main Feb 20, 2025
4 checks passed
@DavisVaughan DavisVaughan deleted the feature/unary-formula branch February 20, 2025 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single sided ~ formulas with non-identifier RHS should add a space

2 participants