Skip to content
Back to formatted view

Raw Message

Message-ID: <m28xjdicxr.fsf@ziti.local>
Date: 2006-10-18T20:30:56Z
From: Seth Falcon
Subject: Error condition in evaluating a promise
In-Reply-To: <4536618D.9070409@gmail.com> (Roger D. Peng's message of "Wed, 18 Oct 2006 13:17:01 -0400")

"Roger D. Peng" <rdpeng at gmail.com> 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 
> the first time.  Afterwards, there's no way to retrieve the dataset associated 
> with 'x'.
>
> Active bindings work in this case, but the problem is that I usually only want 
> to load a large dataset once.

You can do that with active bindings.  Have the function look in an
environment for the data.  If found, return it.  If not, load it into
the env and then return it.

We are using this approach in the BSGenome package in BioC (look there
for an example if you want) and it provides behavior very similar to
lazy data, but more manageable in a number of ways.

+ seth