Many programming languages have a function to evaluate a string as code or an
expression, e.g., eval()
in R. Once you learn it, it becomes tempting to abuse
it. Instead of writing code naturally and directly, you start to think about
writing code that constructs code to be evaluated. For example, instead of
writing 1 + 1
, you may write a monster like this:
eval(parse(text = paste(c(‘1’, ‘1’), collapse = ‘+’)))
This is obviously just a silly example, but I have seen people abuse eval()
in
R many …