Skip to content
Prev 343410 / 398506 Next

Display warning only once in session

You can gain access to the environment of the function by using
environment(myFunc), with either local() or your suggestion of
making a factory function and calling it.
That function, when called, would return a function that warned just
once; it is not a function that warns just once.  You could call it
myFuncFactory and make myFunc itself with myFunc <- myFuncFactory().
That would be equivalent to my example calling local().  The factory
approach is good for making a series of functions, each with its own
state (say counters or random number generators).  local() is
convenient for singleton functions-with-state.  You can also supply an
environment to local() so you can make a set of functions sharing a
common environment.  I think reference classes encapsulate both of
these cases.

Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Aug 25, 2014 at 5:15 PM, Grant Rettke <gcr at wisdomandwonder.com> wrote: