homologist

homologist

Function overriding at compile time

Is there any way to, at compile time overrid ALL functions foo that somebody would wrote in a module A.

I think I can do it overriding def/2. But I feel like i would be using a hammer. Any ideas?

Most Liked

NobbZ

NobbZ

You have to call super explicitly.

But it seems as if you want to use something known as decorators. I’ve seen an experimental package for those years ago, not sure if it still works or is maintained.

At least I remember it had problems with multi headed functions.

The easiest is probably to simply call the logger explicitly at the places you need it…

NobbZ

NobbZ

Or better probably this

def foo(x, y, z) do
  log_stuff(...)
  do_foo(x, y, z)
end

defp do_foo(...)...

This way only the decorator is accessible and doesn’t have an obfuscated name.

Last Post!

dom

dom

If it’s for logging calls or computing statistics, you could use the standard tracing tools in Erlang’s dbg module.

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
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
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130579 1222
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
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

We're in Beta

About us Mission Statement