Abstract

Most dynamic languages allow users to turn text into code using various functions, often named <tt>eval</tt>, with language-dependent semantics. The widespread use of these reflective functions hinders static analysis and prevents compilers from performing optimizations. This paper aims to provide a better sense of why programmers use <tt>eval</tt>. Understanding why <tt>eval</tt> is used in practice is key to finding ways to mitigate its negative impact. We have reasons to believe that reflective feature usage is language and application domain-specific; we focus on data science code written in R and compare our results to previous work that analyzed web programming in JavaScript. We analyze 49,296,059 calls to <tt>eval</tt> from 240,327 scripts extracted from 15,401 R packages. We find that <tt>eval</tt> is indeed in widespread use; R’s <tt>eval</tt> is more pervasive and arguably dangerous than what was previously reported for JavaScript.

Highlights

  • Most dynamic languages provide their users with a facility to transform unstructured text into executable code and evaluate that code

  • We find that eval is in widespread use; R’s eval is more pervasive and arguably dangerous than what was previously reported for JavaScript

  • Reflective facilities have been used to parameterize programs over code patterns that can be provided after the program is written. The presence of such a feature in a language is a hallmark of dynamism; it is a form of delayed binding as the behavior of any particular call to eval will only be known when the program is run, and that particular call site is evaluated

Read more

Summary

Introduction

Most dynamic languages provide their users with a facility to transform unstructured text into executable code and evaluate that code We refer to this reflective facility as eval bowing to its origins in LISP, all the way back in 1956. Reflective facilities have been used to parameterize programs over code patterns that can be provided after the program is written The presence of such a feature in a language is a hallmark of dynamism; it is a form of delayed binding as the behavior of any particular call to eval will only be known when the program is run, and that particular call site is evaluated. The attribute dim-c(2,2) can be attached to the value bound to x by attr(x,"dim")← c(2,2). Once forced, the promise’s result is cached for future use

Objectives
Methods
Findings
Discussion
Conclusion
Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call