vapourlang / vapour

Typed superset of R
http://vapour.run
Apache License 2.0
194 stars 3 forks source link

Macros #7

Open JohnCoene opened 3 months ago

JohnCoene commented 3 months ago

Could we have macros? Are they worth it? What's the runtime overhead of calling a function in R.

JohnCoene commented 2 months ago
foo <- function(x = 2) x + 1
rbenchmark::benchmark("fn" = {foo();foo();foo()}, "macro" = {2 + 1; 2 + 1; 2
     + 1}, replications = 1000)
   test replications elapsed relative user.self sys.self user.child sys.child
1    fn         1000   0.002        2     0.002        0          0         0
2 macro         1000   0.001        1     0.001        0          0         0
JohnCoene commented 2 months ago

A text replacement macro a la C is a bit meh but perhaps a start?