Skip to content

Clarify what specifying the module name does with & #13668

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

Merged
merged 4 commits into from
Jul 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/elixir/lib/kernel/special_forms.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1786,6 +1786,13 @@ defmodule Kernel.SpecialForms do

&local_function/1

When the capture operator is given a module name, a remote/external capture
is created. Remote captures are faster than local captures. For more
information, refer to the ["Functions" section in the Erlang Reference Manual](https://www.erlang.org/doc/system/eff_guide_functions.html#function-calls).
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a bit misleading, because imported functions would also be external, it isn't about the m.f/a syntax:

iex> &to_timeout/1
&Kernel.to_timeout/1

Perhaps the point could be focused on &local_function/1 versus &__MODULE__.local_function/1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the correction! Will do


Note that local captures dispatch to the version of the module which created
them, while remote captures dispatch to the current version of the module.
Copy link
Contributor

Choose a reason for hiding this comment

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

Since hot code reloading is not so common, I think it is worth making this explicit this is only applies in this context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK!


See also `Function.capture/3`.

## Anonymous functions
Expand Down