otuv

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

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

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

otuv

Total turnaround :slight_smile:

It does work and I can remove all of the aliases from the helper.

Last Post!

otuv

otuv

Total turnaround :slight_smile:

It does work and I can remove all of the aliases from the helper.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement