-
Notifications
You must be signed in to change notification settings - Fork 3k
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
erl_eval: Support the fun Name/Arity
syntax for creating a fun
#8987
base: maint
Are you sure you want to change the base?
erl_eval: Support the fun Name/Arity
syntax for creating a fun
#8987
Conversation
Attempting to create a fun referering to either an auto-imported BIF or a local fun defined in shell would fail: 1> fun is_atom/1. ** exception error: undefined function erl_eval:is_atom/1 2> id(I) -> I. ok 3> fun id/1. ** exception error: undefined function erl_eval:id/1 This commit adds support for defining a fun based on either an auto-imported BIF: 1> F = fun is_atom/1. fun erlang:is_atom/1 2> F(a). true 3> F(42). false Or on a local function defined in the shell: 1> I = fun id/1. #Fun<erl_eval.42.18682967> 2> I(42). ** exception error: undefined shell command id/1 3> id(I) -> I. ok 4> I(42). 42 As shown in the example, it not necessary that the local fun is defined at the time the fun is created; only that it is defined when the fun is called. Closes erlang#8963
2d41b4a
to
79b0e0d
Compare
CT Test Results 2 files 95 suites 1h 9m 20s ⏱️ Results for commit 79b0e0d. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks all good!
Nice, thanks for fixing that! |
I'm not sure if there's some work necessary in the debugger to make it work there as well since it has a (partial?) fork of the evaluator |
Attempting to create a fun referering to either an auto-imported BIF or a local fun defined in shell would fail:
This pull request adds support for defining a fun based on either an auto-imported BIF:
Or on a local function defined in the shell:
As shown in the example, it not necessary that the local fun is defined at the time the fun is created; only that it is defined when the fun is called.