Sebb
Is &foo/1 really faster than &foo(&1)
Exercism states, that I should rather capture a function instead of creating a new one.
While this makes sense, it seems to me that this should be an easy task for the compiler to optimize.
In particular I prefer for example &(&1+&2) over &+/2.
Marked As Solved
josevalim
It is not faster. Those are equivalent. ![]()
Also Liked
LostKobrakai
There’s however a difference between &Module.fun/2 vs. any other form. The fully quantified version (mod, fun and arity) can be optimized to not use an anonymous function, which makes it more performant. This is important in situations like :telementry handlers, which might be called very often, as described in the docs:
hauleth
To clarify - difference is meaningful only when that capture crosses process boundary. Within single process it will be unnoticeable or even may be slightly slower when you call local capture within single module.
LostKobrakai
To the contrary. One of the big features of telemetry is that handlers are executed in the process emiting any event, which means there’s no message passing involved in providing data to said handlers – and handlers can then decide how to handle the provided data. That however means the handler is passed around between processes.
LostKobrakai
Seems like it’s a runtime warning when attaching, not a compiler warning.
hauleth
In Telemetry it almost always cross process boundary, that is why Telemetry forces remote captures.







