Re: [Rd] Bug in handling of promises?

2005-03-08 Thread Peter Dalgaard
Duncan Murdoch <[EMAIL PROTECTED]> writes: [snip] > So I tried to explicitly force it: > > > g <- function( H, prevEnv = NULL) { > + if (!is.null(prevEnv)) H <- prevEnv$H > + force(H) > + return(environment(NULL)) > + } > > but this still doesn't work: > > > env <- g( function(x)

Re: [Rd] Bug in handling of promises?

2005-03-08 Thread Duncan Murdoch
A followup: doing an assignment of the value works even after the return: > f function( H ) { cat('Evaluate H to get \n') print(H) return(environment()) } > env <- f( function(x) x^2 ) Evaluate H to get function(x) x^2 > env$H > env$H(1) Error: attempt to apply non-function > H <- e

Re: [Rd] Bug in handling of promises?

2005-03-08 Thread Duncan Murdoch
On Tue, 8 Mar 2005 17:44:41 + (GMT), Prof Brian Ripley <[EMAIL PROTECTED]> wrote : >The following note in ?force may help > >Note: > > 'force' does not force the evaluation of promises. > >It is there because people have been confused before. Yes, but it also says that it "forces the eva

Re: [Rd] Bug in handling of promises?

2005-03-08 Thread Prof Brian Ripley
The following note in ?force may help Note: 'force' does not force the evaluation of promises. It is there because people have been confused before. On Tue, 8 Mar 2005, Duncan Murdoch wrote: I'm working on a function that does adaptive sampling, and I thought it would be handy to return the fu