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

Using mrb_funcall_argv() instead of mrb_funcall_id() #5804

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dearblue
Copy link
Contributor

@dearblue dearblue commented Oct 9, 2022

mrb_funcall_id() is an attractive and easy-to-use function, but it requires more stack space. This is because the mrb_funcall_id() function takes variable-length arguments and also requires copying to a fixed-length array.

If the mrb_funcall_argv() function is called directly, stack consumption can be avoided. However, it requires an array to be defined, making it less usable.

Therefore, the MRB_FUNCALL() macro function is introduced to improve usability. This is for internal implementation at this time, because if the number of arguments is wrong, the error will be hard to understand at compile time.

Currently, only calls with up to 4 arguments are made. For reserve purposes, calls with up to 6 arguments are valid. Calls with 7 to 13 arguments will output a "function not defined" error at compile time. For 14 or more arguments, a seemingly inexplicable error is output.

@dearblue dearblue requested a review from matz as a code owner October 9, 2022 13:40
`mrb_funcall_id()` is an attractive and easy-to-use function, but it requires more stack space.
This is because the `mrb_funcall_id()` function takes variable-length arguments and also requires copying to a fixed-length array.

If the `mrb_funcall_argv()` function is called directly, stack consumption can be avoided.
However, it requires an array to be defined, making it less usable.

Therefore, the `MRB_FUNCALL()` macro function is introduced to improve usability.
This is for internal implementation at this time, because if the number of arguments is wrong, the error will be hard to understand at compile time.

Currently, only calls with up to 4 arguments are made. For reserve purposes, calls with up to 6 arguments are valid.
Calls with 7 to 13 arguments will output a "function not defined" error at compile time.
For 14 or more arguments, a seemingly inexplicable error is output.

Also, `mrb_static_assert_expand()` has been renamed to `MRB_VA_EXPAND()` and moved to `include/mruby/common.h`.
@dearblue
Copy link
Contributor Author

Also, mrb_static_assert_expand() has been renamed to MRB_VA_EXPAND() and moved to include/mruby/common.h.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant