Add the concept of "collection" to the compiler and remove the concept of "in-order AST nodes" #1819
Closed
6 of 7 tasks
Labels
big
this task is hard and will take a while
compiler: codegen
Everything to do with IR->ASM, register allocation, etc.
compiler: collection
Everything to do with graph collection, type collection, and the collection context.
compiler: frontend
Everything to do with type checking, control flow analysis, and everything between parsing and IRgen
enhancement
New feature or request
language feature
Core language features visible to end users
Needs RFC
Features that require an RFC before proceeding with an implementation
P: high
Should be looked at if there are no critical issues left
Milestone
The Problem
Currently, the Sway compiler relies heavily on the concept of the AST nodes being ordered “correctly” in order to perform successful compilation. Out of this comes the additional requirement that dependencies be ordered correctly in a Sway project. The burden of deciding the “correct AST node ordering” is not placed on the user, but on the compiler. Currently, the compiler performs a pass before type checking to determine the correct order in which to type check the AST nodes.
Mathematically, this places restrictions on the dependency structure of a Sway project. Currently, Sway projects must be directed acyclic graphs (a tree).
This creates fundamental issues:
The Solution
The order of AST nodes should not be a factor of importance inside the compiler. I propose that we shift the way that the compiler thinks about AST node ordering, and eliminate the concept of “correct AST node ordering.” This will mean that the order of AST nodes during type-checking will no longer have any effect on the output of the compiler.
This will open up Sway to a new domain of applications, as it would allow Sway projects to be directed cyclic graphs. (two direct mutually recursive dependencies are considered a 1-hop cycle)
I propose these new high-level compiler steps:
The Roadmap
The implementation steps are (roughly) as follows in order:
The original proposal is here: https://docs.google.com/document/d/1kwOk08-Ot7n2RCYCWNNtFCfQAxtlYN-DFHk2sxK139E/edit#
The text was updated successfully, but these errors were encountered: