similar to: Bug in handling of promises?

Displaying 20 results from an estimated 60000 matches similar to: "Bug in handling of promises?"

2013 May 16
3
Substitute / delayedAssign (was: Substitute unaware when promise objects are evaluated)
Duncan, Thank you for the clarification on how delayedAssign works. Should R-level interfaces to promise objects ever become available, I expect they would at time come in handy. On the subject of substitute and delayedAssign, I do have a follow-up question for the list. I'm trying to convert a named list of expression objects into an environment of promise objects. After conversion, each
2013 May 15
1
Substitute unaware when promise objects are evaluated
R-devel, I used the 'substitute' function to create labels for objects inside an environment, without actually evaluating the objects, as the objects might be promises. However, I was surprised to see that 'substitute' returns the expression slot of the original promise even after the promise has been forcibly evaluated. (Doesn't the promise go away after evaluation?) This
2007 Sep 24
1
Inspecting promises
Is there some way of displaying the expression and evaluation environment associated with a promise? I have found the following: > # first run these two commands to set up example > e <- new.env() > delayedAssign("y", x*x, assign.env = e) > # method 1. shows expression but not evaluation environment > str(as.list(e)) List of 1 $ y: promise to language x * x >
2014 Feb 11
1
getting environment from "top" promise
Hi all, It seems that there is a use case for obtaining the environment for the "top" promise. By "top", I mean following the promise chain up the call stack until hitting a non-promise. S4 data containers often mimic the API of base R data structures. This means writing S4 methods for functions that quote their arguments, like with() and subset(). The methods package
2005 Mar 11
3
delay() has been deprecated for 2.1.0
After a bunch of discussion in the core group, we have decided to deprecate the delay() function (which was introduced as "experimental" in R 0.50). This is the function that duplicates in R code the delayed evaluation mechanism (the promise) that's used in evaluating function arguments. The problem with delay() was that it was handled inconsistently (e.g. sometimes you would see
2024 Mar 08
1
Function environments serialize to a lot of data until they don't
Hello R-help, I've noticed that my 'parallel' jobs take too much memory to store and transfer to the cluster workers. I've managed to trace it to the following: # `payload` is being written to the cluster worker. # The function FUN had been created as a closure inside my package: payload$data$args$FUN # function (l, ...) # withCallingHandlers(fun(l$x, ...), error =
2024 May 11
1
[External] R hang/bug with circular references and promises
On Sat, 11 May 2024, Travers Ching wrote: > The following code snippet causes R to hang. This example might be a > bit contrived as I was experimenting and trying to understand > promises, but uses only base R. > > It looks like it is looking for "not_a_variable" recursively but since > it doesn't exist it goes on indefinitely. > > x0 <- new.env() > x1
2024 May 11
1
R hang/bug with circular references and promises
The following code snippet causes R to hang. This example might be a bit contrived as I was experimenting and trying to understand promises, but uses only base R. It looks like it is looking for "not_a_variable" recursively but since it doesn't exist it goes on indefinitely. x0 <- new.env() x1 <- new.env(parent = x0) parent.env(x0) <- x1 delayedAssign("v",
2024 May 11
1
[External] R hang/bug with circular references and promises
On Sat, May 11, 2024 at 9:34?AM luke-tierney--- via R-devel <r-devel at r-project.org> wrote: > > On Sat, 11 May 2024, Travers Ching wrote: > > > The following code snippet causes R to hang. This example might be a > > bit contrived as I was experimenting and trying to understand > > promises, but uses only base R. > > This has nothing to do with promises.
2017 Jul 31
0
force promises inside lapply
quote(expr) will make no changes in expr, it just returns its one argument, unevaluated. substitute could be used in your lapply(..., library) example to give library a name instead of a character string for an input (which might be necessary if the character.only argument were not available) lapply(c("MASS", "splines"), function(pkg) eval(substitute(library(pkg),
2006 Oct 18
1
Error condition in evaluating a promise
Is there a way to raise an error condition when a promise is evaluated such that is can be evaluated again? Right now strange things happen when the evaluation fails: > delayedAssign("x", if (failed) stop("you have to initialize me first!") else foo) > foo <- "I'm foo" > failed<-TRUE > x Error: you have to initialize me first! > x
2017 Sep 18
2
issue with promises for time parameter of rep()
Greetings, The following is based on a question I raised on Stackoverflow: https://stackoverflow.com/questions/46280120/calling-printls-str-in-function-affect-behavior-of-rep/46283979#46283979 Start a new R session with an empty Global Env. Then define: f <- function(n) { print(ls.str()) rep("hello", times = n) } Now run: f(x) Instead of getting the expected "object
2015 Jan 26
2
Inspect a "delayed" assigned whose value throws an error?
On Mon, Jan 26, 2015 at 12:24 PM, Hadley Wickham <h.wickham at gmail.com> wrote: > If it was any other environment than the global, you could use substitute: > > e <- new.env() > delayedAssign("foo", stop("Hey!"), assign.env = e) > substitute(foo, e) > > delayedAssign("foo", stop("Hey!")) > substitute(foo) Hmm... interesting
2009 Jul 29
1
Strange Interaction Between Promises and Closures (PR#13861)
Full_Name: Keith Bare Version: 2.7.1 OS: Linux Submission from: (NULL) (128.2.134.48) I observed unexpected behavior attempting to use lapply to vary parameters in generated closures. All the generated closures ran with the last parameter value in the list. Here's a simple example: > funcs <- lapply(c("alpha", "beta", "gamma", "delta"),
2013 Apr 03
1
Documentation error in subsitute
Hi all, The documentation for substitute currently reads: Substitution takes place by examining each component of the parse tree as follows: If it is not a bound symbol in ?env?, it is unchanged. If it is a promise object, i.e., a formal argument to a function or explicitly created using ?delayedAssign()?, the expression slot of the promise replaces the symbol. If it is an ordinary variable,
2024 May 13
1
[External] R hang/bug with circular references and promises
On Sat, 11 May 2024, Peter Langfelder wrote: > On Sat, May 11, 2024 at 9:34?AM luke-tierney--- via R-devel > <r-devel at r-project.org> wrote: >> >> On Sat, 11 May 2024, Travers Ching wrote: >> >>> The following code snippet causes R to hang. This example might be a >>> bit contrived as I was experimenting and trying to understand >>>
2012 Apr 29
1
A doubt about substitute() after delayedAssign()
Hello, ?delayedAssign presents substitute() as a way to look at the expression in the promise. However, msg <- "old" delayedAssign("x", msg) msg <- "new!" x #- new! substitute(x) #- x (was 'msg' ?) Here, we just got 'x'... shouldn't we got 'msg'? Same result when the promise is not evaluated yet: delayedAssign("x",
2003 Aug 11
1
An inconsistency with promise in attributes
When an attribute is a delayed expression sometimes it is not forced when it is extracted. > x <- list() > attr(x, "p") <- delay(1) > x list() attr(,"p") <promise: 0x11e4bb8> > val <- attr(x, "p") > val [1] 1 > attr(x, "p") <promise: 0x11e4bb8> I am not quite sure whether the above is a bug or not but I think
2015 Jan 26
2
Inspect a "delayed" assigned whose value throws an error?
Hi, I got an interesting programming challenge: How do you inspect an object which is assigned via delayedAssign() and that throws an error as soon as it is "touched" (=the value is evaluated)? Is it possible? MINIMAL EXAMPLE: $ R --vanilla > delayedAssign("foo", stop("Hey!")) (If you find this minimal example silly/obvious, please skip down to the real
2008 Nov 17
4
functional (?) programming in r
the following is a trivialized version of some functional code i tried to use in r: (funcs = lapply(1:5, function(i) function() i)) # a list of no-parameter functions, each with its own closure environment, # each supposed to return the corresponding index when applied to no arguments sapply(funcs, function(func) func()) # supposed to return c(1,2,3,4,5) there is absolutely nothing unusual in