fireproofsocks
Task.start/1 vs. Task.start/3
Just wanting to make sure… there are a handful of functions in the Task module that support different arities, e.g. Task.start/1 vs. Task.start/3, or Task.async_stream/3 vs. Task.async_stream/5. In all cases, the difference boils down to either passing an anonymous function (defined with fn) or using the long-form MFA notation.
From reading a bit about Task — Elixir v1.17.1 and Agent — Elixir v1.17.1, I understand that sometimes you MUST use the more verbose MFA notation to properly designate a function that will execute. Is the MFA notation only required when we are dealing with distributed nodes? Are the shorter function signatures (e.g. Task.start/1) only a convenience, or are there any cases where you would want to require that all instances of the module + function were the same version?
Most Liked
al2o3cr
Mostly it’s a matter of “those are the two ways in the BEAM to identify code that should be turned into a process”; see also the core spawn/1,2,3,4 function.
There are situations where an anonymous function isn’t allowed (for instance, in config) and there are other situations where an MFA can’t name the desired function (for instance, private functions) so both forms are useful.
gregvaughn
Anonymous functions can also cause problems during live module upgrades, a.k.a. hot deploys.







