kuroda
What is the definition of a remote function?
When we try to evaluate an Elixir code m = %{}; m.foo = 1 on IEx, it emits the following error message :
** (CompileError) iex:1: cannot invoke remote function m.foo/0 inside a match
I know that we cannot call m.foo/0 inside a pattern match, but I have some questions:
- What is a remote function exactly?
- What is called a function that is not a remote function?
I cannot find a definition of this word within the documentation.
Perhaps, it refers to a remote call, which is used in the left . right?
Most Liked
kip
A remote function is a function in a module that isn’t this one.
A local function is one defined in the current module.
There is a slight cost in the BEAM to execute a remote function over a local one, but not material to a design decision.
NobbZ
A remote call is every function call which is qualified by its module.
defmodule M do
def f(0), do: 0
def f(n) when n > 0, do: M.f(n-1) + 2
end
The recursive call here is a remote call, with all of its costs.
hauleth
That is not fully true as __MODULE__.foo() is also remote call. In short the difference between remote and local call is that you put the module name before remote call.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









