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

RFC: preserve more syntax in parsing ?, do, and elseif #23061

Closed
wants to merge 1 commit into from

Conversation

JeffBezanson
Copy link
Sponsor Member

A part of #21774 that I find pretty agreeable.

  • ? - just uses ? as the expression head instead of if
  • do parses as (do <function call expr> <function argument expr>)
  • if parses the same as before, except nested ifs that come from elseif use elseif as the expression head instead of if, and are nested directly inside the if expression without intervening blocks, line nodes, etc. I also tried a flat representation (adding N arguments to if), but it was hard to deal with. The nested structure is easier since you only need to write code to handle 2- or 3-argument if, and treat elseif the same as if.

This should be non-breaking for users, and a living nightmare for macro authors :)

@JeffBezanson JeffBezanson added breaking This change will break code needs news A NEWS entry is required for this change parser Language parsing and surface syntax labels Jul 31, 2017
@@ -13,13 +13,13 @@ such as a `ccall` to a non-existent function.
"""
macro static(ex)
if isa(ex, Expr)
if ex.head === :if || ex.head === :&& || ex.head === :||
if ex.head === :if || ex.head === :&& || ex.head === :|| || ex.head === :?
Copy link
Contributor

Choose a reason for hiding this comment

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

should @static also statically resolve elseif conditions?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

It could, but that would be more of a new feature, since it was never able to before.

@tkelman
Copy link
Contributor

tkelman commented Aug 1, 2017

does

if ex.head == :if
need updating to handle the possibilities of ternary and elseif now that they're separate?

@JeffBezanson
Copy link
Sponsor Member Author

Yes, it should be updated for ?. Like @static, it only handled the outermost if, so elseif should not be needed to support current uses.

@JeffBezanson JeffBezanson added this to the 1.0 milestone Aug 2, 2017
@ararslan
Copy link
Member

ararslan commented Aug 3, 2017

@nanosoldier runbenchmarks(ALL, vs=":master")

@JeffBezanson
Copy link
Sponsor Member Author

I will break this into smaller PRs.

@ararslan ararslan deleted the jb/ast1 branch August 3, 2017 22:29
@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@ararslan
Copy link
Member

ararslan commented Aug 3, 2017

It's TOO LATE, Nanosoldier.

@KristofferC KristofferC removed the needs news A NEWS entry is required for this change label Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This change will break code parser Language parsing and surface syntax
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants