otuv
Passing private functions
Hi,
I have a simple helper function to clock stuff.
I want to put it in a my X.Helper module (assuming my project is X) to use it wherever I need.
def clock(mark, fun, args) do
{time, result} = :timer.tc(fun, args)
IO.puts(mark <> ": #{Kernel.inspect(result)} Time: #{time} μs")
result
end
But when I pass a function from the module Y I get an error module Y is not available
Reluctantly (as it would break the decoupling) I tried to alias the Y function but that does not seem to work either.
What is the common approach to this kind of stuff?
Marked As Solved
NobbZ
Ah, now I remember…
&M.f/a exposes the remote call to the receiving module, which then isn’t allowed to do that, you need to omit the module name and do Helpers.clock("Append", &append_as_binary/2, [data_path(key), value]) instead…
Also Liked
NobbZ
Could you please tell us the exact error you get?
From a first glance over what we have seen so far, it should work.
otuv
Total turnaround 
It does work and I can remove all of the aliases from the helper.







