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

[SR-5832] Eliminate curried function representation from ASTs #48402

Closed
lattner mannequin opened this issue Sep 4, 2017 · 3 comments
Closed

[SR-5832] Eliminate curried function representation from ASTs #48402

lattner mannequin opened this issue Sep 4, 2017 · 3 comments
Assignees
Labels
compiler The Swift compiler in itself good first issue Good for newcomers improvement

Comments

@lattner
Copy link
Mannequin

lattner mannequin commented Sep 4, 2017

Previous ID SR-5832
Radar None
Original Reporter @lattner
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, StarterBug
Assignee @slavapestov
Priority Medium

md5: 3408999bc5c0a3bd8274b1aacdd5e271

Issue Description:

Curried function syntax was removed in Swift 3, and Swift 4 carries the tech debt from them for migration purposes. Now that Swift 4 has branched, we can remove the AST representation and simply parse and reject them in the parser. We still have curried functions, because methods carry a curried self parameter, but we now know we have either 1 or 2 parameter lists, not an unbounded number. Be aware that deinit's are a special case because they just have a self parameter, not a self param + a normal param list.

Specifically, this stuff should be simplified:

remove "NumParameterLists". We can determine whether there is one or two https://github.com/apple/swift/blob/master/include/swift/AST/Decl.h#L364

AbstractFunctionDecl should take a two parameter list instead of an array of them, and store them inline instead of a separate allocation:

https://github.com/apple/swift/blob/master/include/swift/AST/Decl.h#L4846

Simplify everything that passes these down to AFD, and simplify the clients.

The existing getParameterLists() function should remain, but it makes sense to add a new "getSelfParameterList()" and "getNormalParameterList()" method to simplify clients that only care about one or the other.

@JGiola
Copy link
Contributor

JGiola commented Oct 27, 2017

If this is still up to grab, I can try a run for it.

Only twi things, what is the parameter to pass to the --filter for running only the tests for the AST and the ninja command to rebuild it without full one? I still can't grasp how to find them 🙂

@slavapestov
Copy link
Member

I'm currently working on this: #18082

@slavapestov
Copy link
Member

I'm going to say this is resolved: #18139

I took a slighly different approach than the one outlined in this bug:

  • There's no ParameterList for self. Self is enough of a special case that it's not useful to build a single-element ParameterList for it. Instead, the AbstractFunctionDecl constructor takes a ParamDecl for self and a ParameterList for the normal parameters.
  • getParameterLists() is gone, because again, all clients that look at parameter lists were giving 'self' special treatment anyway.
  • I'm not storing the parameter array itself inline. Getting the parameter list of a function still requires dereferencing a pointer. In the future we might want to investigate storing the parameter array inline, but right now there are enough places that want to treat a ParameterList as a first-class entity that it would be difficult to do this.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself good first issue Good for newcomers improvement
Projects
None yet
Development

No branches or pull requests

2 participants