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

Experiment: Make macros bind stronger than commas within parentheses #212

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

c42f
Copy link
Member

@c42f c42f commented Mar 3, 2023

As discussed in JuliaLang/julia#36547

That is, f(@x a, b) parses as

(call f (macrocall a) b)

rather than

(call f (macrocall (tupel a b)))

Unfortunately, this is mildly breaking, due to such strange syntax as (@unpack a,b = c)

@codecov
Copy link

codecov bot commented Mar 3, 2023

Codecov Report

Attention: Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 96.68%. Comparing base (2a0efad) to head (0a0ffa3).
Report is 85 commits behind head on main.

Files Patch % Lines
src/parse_stream.jl 86.66% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #212   +/-   ##
=======================================
  Coverage   96.68%   96.68%           
=======================================
  Files          14       14           
  Lines        4007     4008    +1     
=======================================
+ Hits         3874     3875    +1     
  Misses        133      133           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@c42f c42f marked this pull request as draft March 3, 2023 22:26
@c42f c42f force-pushed the c42f/macro-comma-binding branch 2 times, most recently from bb5a263 to 244be72 Compare May 12, 2023 06:30
c42f and others added 3 commits May 13, 2023 05:40
That is, `f(@x a, b)` parses as

    (call f (macrocall a) b)

rather than

    (call f (macrocall (tupel a b)))

Unfortunately, this is mildly breaking, due to such strange syntax as
`(@unpack a,b = c)`
Also enable it within concatenation syntax for consistency
@nsajko
Copy link

nsajko commented Jun 25, 2024

Perhaps it'd make sense to deprecate f(@x a, b) and/or introduce warnings, but changing the semantics from one valid interpretation to another would be horrible. Please don't do it before Julia v2.

@c42f
Copy link
Member Author

c42f commented Jul 18, 2024

changing the semantics from one valid interpretation to another would be horrible

It's "horrible", but evidence suggests that users don't understand the existing precedence and actively write bugs with the existing semantics. Look at the analysis here

If we fix more cases in the ecosystem than we break by making this change, is that actually "horrible"? There's no right answer, only tradeoffs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants