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

Compiler: simplify some calls #12417

Merged
merged 2 commits into from
Sep 3, 2022
Merged

Compiler: simplify some calls #12417

merged 2 commits into from
Sep 3, 2022

Conversation

asterite
Copy link
Member

There are Call constructors that take one or two call arguments.
Use those instead of passing an array.
I also added a new overload that takes three arguments. I think
0..3 arguments is the most common case in the compiler.

This shouldn't affect anything, but it might make things a bit easier
if we ever decide to change Call@args to another type.

There are Call constructors that take one or two call arguments.
Use those instead of passing an array.
I also added a new overload that takes three arguments. I think
0..3 arguments is the most common case in the compiler.

This shouldn't affect anything, but it might make things a bit easier
if we ever decide to change `Call@args` to another type.
end

def self.new(obj, name, arg1 : ASTNode, arg2 : ASTNode)
new obj, name, [arg1, arg2] of ASTNode
end

def self.new(obj, name, arg1 : ASTNode, arg2 : ASTNode, arg3 : ASTNode)
Copy link
Member Author

Choose a reason for hiding this comment

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

I know at this point we could maybe use a splat, but I'd like to avoid creating intermediate tuples. 0..3 is enough.

@asterite asterite marked this pull request as ready for review August 29, 2022 20:35
@straight-shoota
Copy link
Member

I'm wondering if we can ensure to prefer these API methods for small argument lists in the future.

@asterite
Copy link
Member Author

I'm wondering if we can ensure to prefer these API methods for small argument lists in the future

We could do that if we used a linter for the project.

@asterite
Copy link
Member Author

In any case I think we can merge this without waiting for a linter, right?

@straight-shoota straight-shoota added this to the 1.6.0 milestone Sep 1, 2022
@asterite asterite merged commit 7958de3 into master Sep 3, 2022
@asterite asterite deleted the cleanup/simplify-some-calls branch September 3, 2022 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants