Duncan Murdoch <murdoch.dun...@gmail.com> writes:

> On 12-01-06 10:21 PM, Rolf Turner wrote:
>> On 07/01/12 15:51, R. Michael Weylandt<michael.weyla...@gmail.com>  wrote:
>>> I imagine the answer will involve lazy evaluation and require you use 
>>> force() but I'm not quite qualified to pronounce and not at a computer to 
>>> test.
>>
>> I think you've got it;  I tried
>>
>> junk<- vector("list",4)
>> for(i in 1:4) {
>>      junk[[i]]<- eval(bquote(function(x){42 + .(force(i))*x}))
>> }
>>
>> and got the result that I wanted.  Still don't completely understand, but
>> it at least makes vague sense and makes me a bit more comfy.
>
> I'm not so sure.  The index in a for loop isn't supposed to be a
> promise.  To me, it looks like a bug, maybe in bquote()...
>

Duncan,

IIUC, the promise is created by bquote().

Replacing

        eval(e[[2L]], where)
by
        {
        e[[1L]] <- as.name("force")
        eval(e)
        eval(e[[2L]], where)
         } 

seems to handle this case without breaking example(bquote).


HTH,

Chuck

> Duncan Murdoch
>

-- 
Charles C. Berry                            Dept of Family/Preventive Medicine
cberry at ucsd edu                          UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to