Re: [Rd] Error condition in evaluating a promise

2006-10-18 Thread Duncan Murdoch
On 10/18/2006 1:17 PM, Roger D. Peng wrote: > I've encountered a (I think) related problem when using promises to load > relatively large datasets. For example something like > > delayedAssign("x", getBigDataset()) > > runs into the same problem if you hit Ctrl-C while 'x' is being evaluated fo

Re: [Rd] Error condition in evaluating a promise

2006-10-18 Thread Seth Falcon
"Roger D. Peng" <[EMAIL PROTECTED]> writes: > I've encountered a (I think) related problem when using promises to load > relatively large datasets. For example something like > > delayedAssign("x", getBigDataset()) > > runs into the same problem if you hit Ctrl-C while 'x' is being evaluated for

Re: [Rd] Error condition in evaluating a promise

2006-10-18 Thread Luke Tierney
On Wed, 18 Oct 2006, Simon Urbanek wrote: > > On Oct 18, 2006, at 1:17 PM, Roger D. Peng wrote: > >> I've encountered a (I think) related problem when using promises to >> load relatively large datasets. For example something like >> >> delayedAssign("x", getBigDataset()) >> >> runs into the same

Re: [Rd] Error condition in evaluating a promise

2006-10-18 Thread Simon Urbanek
On Oct 18, 2006, at 1:17 PM, Roger D. Peng wrote: > I've encountered a (I think) related problem when using promises to > load relatively large datasets. For example something like > > delayedAssign("x", getBigDataset()) > > runs into the same problem if you hit Ctrl-C while 'x' is being > e

Re: [Rd] Error condition in evaluating a promise

2006-10-18 Thread Roger D. Peng
I've encountered a (I think) related problem when using promises to load relatively large datasets. For example something like delayedAssign("x", getBigDataset()) runs into the same problem if you hit Ctrl-C while 'x' is being evaluated for the first time. Afterwards, there's no way to retrie

Re: [Rd] Error condition in evaluating a promise

2006-10-18 Thread Robert Gentleman
Simon Urbanek wrote: > Seth, > > thanks for the suggestions. > > On Oct 18, 2006, at 11:23 AM, Seth Falcon wrote: > >> Simon Urbanek <[EMAIL PROTECTED]> writes: >>> thanks, but this is not what I want (the symbols in the environment >>> are invisible outside) and it has nothing to do with the

Re: [Rd] Error condition in evaluating a promise

2006-10-18 Thread Luke Tierney
Active bindings are another option (?makeActiveBinding). It might be worth revisiting how promises are evaluated to see if at elast a more sensible error message can be achieved, but making sure any changes do not affect performance will be tricky. Best, luke On Wed, 18 Oct 2006, Duncan Temple

Re: [Rd] Error condition in evaluating a promise

2006-10-18 Thread Simon Urbanek
Seth, thanks for the suggestions. On Oct 18, 2006, at 11:23 AM, Seth Falcon wrote: > Simon Urbanek <[EMAIL PROTECTED]> writes: >> thanks, but this is not what I want (the symbols in the environment >> are invisible outside) and it has nothing to do with the question I >> posed: as I was saying i

Re: [Rd] Error condition in evaluating a promise

2006-10-18 Thread Duncan Temple Lang
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Simon. One approach is RObjectTables. This provides a way to customize how variables are accessed/assigned in an environment and so allows an operation to do something to compute the value of a variable while still allowing it to be used as a var

Re: [Rd] Error condition in evaluating a promise

2006-10-18 Thread Seth Falcon
Simon Urbanek <[EMAIL PROTECTED]> writes: > thanks, but this is not what I want (the symbols in the environment > are invisible outside) and it has nothing to do with the question I > posed: as I was saying in the previous e-mail the point is to have > exported variables in a namespace, but t

Re: [Rd] Error condition in evaluating a promise

2006-10-18 Thread Simon Urbanek
Martin, On Oct 17, 2006, at 11:43 PM, Martin Morgan wrote: > I believe the technique is to create an environment in the > namespace, and then to access that through functions: > thanks, but this is not what I want (the symbols in the environment are invisible outside) and it has nothing to d

Re: [Rd] Error condition in evaluating a promise

2006-10-18 Thread Prof Brian Ripley
As is clear from the message you got, promises were originally implemented to handle lazy evaluation of closure arguments, as essentially transient objects. There are several aspects of their implementation that are tailored to that use, one being that they can only be evaluated once (as a loo

Re: [Rd] Error condition in evaluating a promise

2006-10-17 Thread Martin Morgan
I believe the technique is to create an environment in the namespace, and then to access that through functions: sandbox/NAMESPACE export(getx, setx) sandbox/R/sandbox.R: sandbox <- new.env(parent=emptyenv()) getx <- function() sandbox$x setx <- function(val) sandbox$x <- val > library(sandbox)

Re: [Rd] Error condition in evaluating a promise

2006-10-17 Thread Simon Urbanek
On Oct 17, 2006, at 8:33 PM, Martin Morgan wrote: >> delayMe <- function() { > + if (failed) { > + delayedAssign("x", delayMe(), assign.env=topenv()) > + stop("init me!") > + } else foo > + } >> >> failed <- TRUE >> foo <- "is me" >> delayedAssign("x", delayMe()) >> x > Er

Re: [Rd] Error condition in evaluating a promise

2006-10-17 Thread Martin Morgan
> delayMe <- function() { + if (failed) { + delayedAssign("x", delayMe(), assign.env=topenv()) + stop("init me!") + } else foo + } > > failed <- TRUE > foo <- "is me" > delayedAssign("x", delayMe()) > x Error in delayMe() : init me! > x Error in delayMe() : init me! > faile

[Rd] Error condition in evaluating a promise

2006-10-17 Thread Simon Urbanek
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