metaprogramming


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
You cannot. Those are defined as special forms (Kernel.SpecialForms) and they cannot be overridden.
Not the answer to your direct question, but if you really want to trace function calls and do some analysis, you may consider Erlang tracing capabilities. I provided a simple example in this answer.
Also, you might look into fprof for profiling, which can give you function count. IIRC fprof analyzes only the process in which you start it, and you can't run multiple profiles simultaneously.

Related Links

What is Declarative Meta-Programming?
Reconsolidate protocols in Elixir 1.2 or higher
Inserting an AST into a quote do end block without unquoting it
Transform quoted elixir code to a code string
Pattern matching benchmarking : Compiletime lookup vs Runtime lookup in D
Meta construction capabilities?
How to manipulate the value of variables based on an array of symbols in Julia?
Multiple #:build macros
Julia automatically generate functions and export them
Dealing with end keyword in macros for array indices
Implementation of AnyMap and runtime overhead of `struct Port(u32);`
Can function application be overriden with Macro in Elixir?
“Registering” trait implementations + factory method for trait objects
Statement list composition
Rust syntax extension and traits
converting strings to formula objects in Julia

Categories

HOME
android
cygwin
embedded
adal
delphi-7
merge
twig
jelastic
requirements
appcelerator
ms-access-2016
static-site
spring-data-mongodb
dojo
ado.net
regular-language
settings
python-multithreading
crystal-lang
bing-maps
extjs4.2
reactive-programming
pega
java.util.logging
redis-sentinel
nancy
alpacajs
nim
swagger-2.0
lilypond
google-maps-autocomplete
ag
react-toolbox
joptionpane
direct3d11
froala
iis-express
zend-debugger
mustache
quickfixj
hibernate-validator
gojs
android-maps-extensions
dynamic-jasper
swagger-php
nohup
z-notation
bc
gdata
typesafe-config
laravel-elixir
preloader
strftime
phpdbg
identification
amq
java-bytecode-asm
oracleclient
pacemaker
segment-io
jodd
x-tag
cfchart
asyncdisplaykit
vhosts
themoviedb-api
fiware-monitoring
pypiserver
wiredep
oracle-spatial
jdi
zen-cart
binomial-theorem
text-search
uncompress
botan
jquery-forms-plugin
apache-spark-1.3
cosine-similarity
appserver
named-parameters
cancellation
buffering
renderer
xmltodict
openargs
away3d
mongohq
octal
font-awesome-4.0.0
curb
uimanageddocument
fitbounds
role
saxparseexception
matlab-load
cgbitmapcontextcreate
dataform
msr
resharper-6.0
scrollbars
skype4java
fail-fast-fail-early
netbeans6.1

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App