title: Get namespace of function
body: <p>I'm developing a package where I wish to add an edit history to an object. The package allows other packages to register functions for editing the object. I'm looking for a way to record the version of the package that registered the function that was used for the edit.</p>
  
  <p>The question is: Given a function how do you get the package from where it was exported? My idea is to investigate its search path, but <code>search()</code> only reports the search path for the current environment and thus not for a function, which is what I need.</p>
  
  <p>Any pointers to other approaches is greatly appreciated.</p>
  
  <p>The context for getting the package is this:</p>
  
  <pre><code>registerFunction &lt;- function(fun) {
    package &lt;- getPackage(fun)  ## This is what I need
    version &lt;- getPackageVersion(package)
    register(fun, package, version)
  }
  </code></pre>