axelson
Documentation of what an "MFA" is?
Is there anywhere that “MFA” is described in detail in the official Elixir documentation? I’ve tried to find it before but was unable to. Am I just missing it somewhere?
(I know what it is I just to have somewhere to link to in my own documentation for anyone unfamiliar with the concept).
Most Liked
peerreynders
In context of typespecs:
mfa() {module(), atom(), arity()}
For child_spec() Erlang uses mfargs() to refer to a {M,F,A} tuple (module, function atom, arguments list - Kernel.apply/3, :erlang.apply/3).
kip
Its a good question! The nearest I could find was an erlang type definition in the docs at Types and Function Specifications — Erlang System Documentation v29.0.2
tfwright
This has recently come up for me as I am working on a library where I am adding support for a “function reference” argument. Previously I was expecting {module, function, args} even though the args component was not really used for anything simply because that format seems to be universal in Elixir. But due to a behavior change I really need to know what arity to expect and I’m sort of at a loss when it comes to best practice!
I am using NimbleOptions and there is no built in support for this. In fact, the documentation has this line which was puzzling to me right off the bat:
:mfa- A named function in the format{module, function, arity}wherearityis a list of arguments. For example,{MyModule, :my_fun, [arg1, arg2]}.
(There is also {:fun, arity} but in my use case the module is also variable, edit: and also on closer reading this appears to be for functions of set arity?)
I have to wonder why it seems that in Elixir mfa has come to mean specifically the args variation and I don’t think I’ve seen a mfargs type in the wild…
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









