Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can function application be overriden with Macro in Elixir?

Let's say I'd want to override each function call with a macro that counts how many times I called each particular function.
Is it possible in Elixir?

I know there is a possibility of overriding builtin macros and functions with

import Kernel, except: [name: arity]
import MyOwnKernel

But it doesn't seem to work for apply/2 nor apply/3

like image 916
Krzysztof Wende Avatar asked Feb 11 '23 07:02

Krzysztof Wende


1 Answers

You cannot. Those are defined as special forms (Kernel.SpecialForms) and they cannot be overridden.

like image 106
José Valim Avatar answered Mar 23 '23 08:03

José Valim