forked from erlang/otp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
erl_eval: Support the fun Name/Arity syntax for creating a fun
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.
- Loading branch information
Showing
2 changed files
with
47 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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