Hello, I was hoping to build some promise evaluations and put them into a call to be evaluated, but it doesn't seem as though there's an easy way to build the promises. I can see from the r-source repository that the C function mkPROMISE defined in Defn.h is what I need, but that file doesn't seem to be included when downloaded (R.home("include") does not contain this file). I'm not particular about whether this has to be done at the R level or at the C level, any solution is good to me. Just in case anyone is wondering "why don't you just evaluate the call in the same environment as you would assign to the promises?", I want to evaluate the function and the first argument in my own environment, and the rest of the arguments in an environment of the user's choosing, and I can't do that without promises. Another question "why don't you use the argument ... in your function to pass arguments which will be evaluated in the user's environment?", I can't do that either. The user's arguments are provided as a string from which the R code is extracted, parsed, and then I can make use of them. Any help is greatly appreciated! Regards, Andrew Simmons
iuke-tier@ey m@iii@g oii uiow@@edu
2022-May-12 16:30 UTC
[R] [External] Building promise evaluations
Promises are an internal implementation detail that could change or even disappear at any time. They should not be directly visible at the R or package C level, the fact that they currently might be in some case notwithstanding. delayedAssign is the only tool you can use for programmatically creating delayed bindings in an environment (which happen to currently be implemented via promises, but that could change). Deferred evaluations should only exist in environments, not anywhere else. So you should arrange what your are trying to do to create a deferred binding in an environment in which you evaluate your call. Best, luke On Thu, 12 May 2022, Andrew Simmons wrote:> Hello, > > > I was hoping to build some promise evaluations and put them into a > call to be evaluated, but it doesn't seem as though there's an easy > way to build the promises. I can see from the r-source repository that > the C function mkPROMISE defined in Defn.h is what I need, but that > file doesn't seem to be included when downloaded (R.home("include") > does not contain this file). > > I'm not particular about whether this has to be done at the R level or > at the C level, any solution is good to me. > > Just in case anyone is wondering "why don't you just evaluate the call > in the same environment as you would assign to the promises?", I want > to evaluate the function and the first argument in my own environment, > and the rest of the arguments in an environment of the user's > choosing, and I can't do that without promises. Another question "why > don't you use the argument ... in your function to pass arguments > which will be evaluated in the user's environment?", I can't do that > either. The user's arguments are provided as a string from which the R > code is extracted, parsed, and then I can make use of them. Any help > is greatly appreciated! > > > Regards, > Andrew Simmons > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Luke Tierney Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics and Fax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke-tierney at uiowa.edu Iowa City, IA 52242 WWW: stat.uiowa.edu