Description Usage Arguments Details See Also Examples
Create a logged copy of a function. Every time the new function is called, all three functions are called in order:
pre
f
post
1 2 3 4 5 | ## S3 method for class 'function'
.tron(x, pre, post = pre)
## S3 method for class 'function'
.troff(x)
|
x |
a function to decorate |
pre |
a function, to be called before |
post |
a function, to be called after |
Wrapped functions carry a “tron” attribute, which can be tested for
using is.tron
. The original function f
can be extracted
using troff
.
http://en.wikipedia.org/wiki/Decorator_pattern and memoise
for another example of “decorator” functions.
1 2 3 4 5 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.