Support starred arguments as class bases#1170
Merged
slozier merged 1 commit intoIronLanguages:masterfrom Apr 13, 2021
Merged
Conversation
slozier
reviewed
Apr 13, 2021
Contributor
slozier
left a comment
There was a problem hiding this comment.
Looks good to me! Though when I find a bit of time I'll probably go through the codebase to eliminate Arg. 😄
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.
@slozier I know you are not a huge fan of
Compiler.Ast.Arg, but the reason I changed the type ofClassDefinition.Basesfrom a ro list ofExpressionto a ro list ofArgis to align it more closely withCallExpression. PEP 3115 specifically declares that:so ideally this should be handled by the same code path as a function call. Indeed, this is what I think CPython does with routing class creation with a call to the internal
__build_class__function.I looked first at implementing it here too, but eventually decided not to go ahead with such approach. The way how arguments are handled in
CallExpressionis tailored to what the DLR supports, which in turn does what it does to implement sophisticated overload resolution for .NET. On the other hand,ClassDefinitionis optimized to callPythonOps.MakeClassdirectly, which in turn uses extra parameters to make a class efficiently.Hence handling of class arguments is done separately from handling of function call arguments, except for some overlap in the parser. So unfortunately, when changes are made (e.g. Python 3.5 allows multiple starred arguments), this will have to be implemented in two places. To ease that, I wanted to keep both parts of the code aligned as much as possible without compromising on efficiency.