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

Context expression being parenthesized #129

Open
leana8959 opened this issue Sep 2, 2024 · 1 comment
Open

Context expression being parenthesized #129

leana8959 opened this issue Sep 2, 2024 · 1 comment

Comments

@leana8959
Copy link

Hello,

I noticed that (after commit 2cab26dc9d6dcd31115c65a3eec43689020ae654), functions where the entire body is in a context keyword is parenthesized. Was this intended ?
This doesn't affect let bindings that are not functions.

I thought that, compared to how if statements are not enclosed in parentheses, this is a bit inconsistent.

Example:

Before
#let foo() = context {
  5
}
After
#let foo() = (
  context {
    5
  }
)
`if` expressions are not in parentheses
#let foo() = if true {
  5
} else {
  6
}

Thanks a lot and have a nice day :)

@Enter-tainer
Copy link
Owner

Enter-tainer commented Sep 3, 2024

This is related to #114 regards to parenthesizes around expressions. Ideally, we should maintain the length of the first line of the expression, if the length of #let foo() = context { exceed the column width, we should switch to

#let foo() = (
  context {
    ...  
}
)

However this is hard to implement in currect pretty printer. The current behavior is that, if the whole thing on the rhs of = cannot fit in a single line, a parenthesize will be added around it.

I cannot remember why I decide to do this. Maybe this is because changing this can make my testset looks better.

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

No branches or pull requests

2 participants