Hi Evan,
You may find some parts of what we are doing with genthat useful. Genthat
is a tool
for creating unit tests by recording argument and return values of calls.
This is
done by instrumentation of the source code.
The git repo with the code is here https://github.com/PRL-PRG/genthat
We don?t really deal with NSE though. It could be something worth thinking
about for us.
The contact for genthtat is Filip.
We are also writing a tool for analyzing promises and generating execution
traces
within the R VM. This is available in
https://github.com/PRL-PRG/R-dyntrace
Aviral and Konrad are the contacts there.
Best,
jan
Jan Vitek, Professor
Computer Science,
Northeastern University
On Jan 3, 2018, at 7:18 PM, Peter Meilstrup <peter.meilstrup at gmail.com>
For 2), it is not exposed in R's standard library but it is exposed in
the Rinternals API. A promise that is forced in normal evaluation will
have PRENV set to NULL.
Peter
On Tue, Jan 2, 2018 at 4:19 PM, Evan James Patterson
<epatters at stanford.edu> wrote:
Hello R experts,
I plan to develop a tool for dynamic analysis of R programs. I would
like to trace function calls at runtime, capturing argument and return
values. Following a suggestion made some time ago on this list, my
high-level implementation strategy is to rewrite the AST, augmenting call
expressions with pre-call and post-call shims to capture the arguments and
return value, respectively.
I can think of only one fundamental conceptual obstacle to this
approach: R functions are not necessarily referentially transparent. The
arguments received by a function are not values but promises. They can be
evaluated directly ("standard evaluation"), after applying arbitrary
syntactic transformations ("non-standard evaluation", aka NSE), or not at
all. Therefore, if you peek at the values of function arguments before
evaluating the function, you risk altering the semantics of the program,
possibly fatally.
I'm looking for general advice about how to cope with NSE in this
context. I also have some specific questions:
1) Is it possible to determine whether a given function (primitive, in
R, or external) uses NSE on some or all of its arguments?
2) Is it possible to inspect the promise objects received by functions,
say to determine whether they have been evaluated, without actually
evaluating them? The R manual is not encouraging in this area:
Thank you,
Evan
[[alternative HTML version deleted]]