4 ms·
I understand her point to be about passing called functions. Surely passing functions as values (partials, etc) is fine? final_function(maybe_function(X)) v
by nathancahill 11y ago
I understand her point to be about passing called functions. Surely passing functions as values (partials, etc) is fine?
final_function(maybe_function(X))
vs
final_function(maybe_function)(x)
Disclaimer, not familiar with Erlang syntax, so the above example is psuedo-code.
"If you need more than 3 levels of indentation, you're screwed anyway, and should fix your program." --Linus
- kungfooguru 11y agoRight, you can pass a function: final_function(fun() -> maybe_function(X) end) or final_function(maybe_function, X) if final_function does: final_function(Function, X) -> Function(X).
- oinksoft 11y agoSmall thing, but `final_function` here needs to be passed `fun maybe_function/1`, not the atom `maybe_function` alone.
- kungfooguru 11y agoOops, yup. Meant to make it explicit since you can also do: ?MODULE:Function(X)