I used R for a while to do visualizations, but I never got to it's more homoiconic side, but I saw since then that it has it.
Can you also put code into { 6 }, like { print(6) }?
Does this overwrite R's if or how does the scoping in R work?
Can you also put code into { 6 }, like { print(6) }?
Does this overwrite R's if or how does the scoping in R work?
Typically, you'd want to parse the unevaluated code, though:
> `if` = function(a, b) { print(substitute(a)); print(substitute(b)) }
> if (foo) { print("bar") }
foo
{
print("bar")
}
It overwrites `if`, in the current scope, of course.