Repository navigation
Add overloads - #774
Draft
bvisness wants to merge 3 commits into
Draft
Add overloads#774bvisness wants to merge 3 commits into
bvisness wants to merge 3 commits into
Conversation
Just a bunch of drive-by updates made as part of union/overload work.
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for function overloading. The design of overloads changed a bit to have optional suffixes of the form
#foo, which can be applied to any function (except getters and setters).Although I would consider this code fairly complete, I'm actually not sure overloads are a worthwhile feature in the component model. I personally wouldn't be super comfortable landing this until we're farther along in our web preview efforts and have more evidence that it would benefit developers.
Resolves #742, depends on #766.
I chose to use
#foosyntax for overload suffixes, because the rules for name uniqueness and parsing just got more confusing and ambiguous when I tried to stick with.foo. (There was a lot of dot-counting, and fussy rules like "if the name has the[method]attribute, get the thirdlabel, else get the secondlabel".)Also, name uniqueness got more complicated. It used to be that strong uniqueness could be computed by just canonicalizing names and chucking them into a hash set. But overloads inherently cause problems with this whole approach. Suppose we have
foo-bar,foo#bar, and[method]foo.foo.foo-barandfoo#barshould clearly conflict, as shouldfoo#barand[method]foo.foo. Butfoo-barand[method]foo.fooshould not! The problem is thatfoo-barandfoo#barconflict on their fully-qualified names, whilefoo#barand[method]foo.fooconflict on their base names. If we are going to avoid practical problems for bindings generators, the strong uniqueness algorithm needs to incorporate both.I won't recap exactly how I reconciled this here, since it's pretty detailed in the patch, but I did my best to ensure that it could still be implemented very simply and efficiently, and still with an algorithm based on name canonicalization.