deparse can help:
> deparse( temp.fun ) [1] "function () " "{" "}"
Going further with the details of your comment, you can create a class that outputs a function and passes this instead of a function.
setClass( "myFunction", contains = "function" ) setMethod( "as.character", "myFunction", function(x, ...){ deparse( unclass( x ) ) } )
So, when you pass the function to a third-party package, you pass myFunction instead:
f <- new( "myFunction", function(){} ) as.character(f)
source share