Skip to content
Prev 302563 / 398503 Next

Force evaluation of a symbol when a function is created

Duncan, et.al:

Many thanks: let the closure do the work automatically rather than
manually manipulating it.

However, in the spirit of the OP's original request, I believe the
call would be:
But then there is no need for force(), is there?
[1] 10
[1] 10
[1] 15

That is, one simply relies on lexical scoping/closures to "retain" the
value of  Y used as a free variable in  function(x)x*Y when it is
defined. No need to explicitly force() it. If wrong, I would be
grateful for correction. This appears to me to duplicate the Matlab
behavior rather closely.


-- Bert
On Tue, Aug 7, 2012 at 3:48 AM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: