From bill at insightful.com  Thu Jun 14 23:05:42 2007
From: bill at insightful.com (Bill Dunlap)
Date: Thu, 14 Jun 2007 14:05:42 -0700 (PDT)
Subject: [Rd] package check note: no visible global function definition
 (in functions using Tcl/Tk)
In-Reply-To: <Pine.LNX.4.64.0706141606001.19996@gannet.stats.ox.ac.uk>
References: <466D5A0F.2090907@tu-dresden.de>
	<Pine.LNX.4.64.0706111638530.22283@gannet.stats.ox.ac.uk>
	<m2abv6v3ba.fsf@ziti.local>
	<Pine.LNX.4.64.0706141606001.19996@gannet.stats.ox.ac.uk>
Message-ID: <Pine.GSO.4.56.0706141353140.5109@durian.statsci.com>

On Thu, 14 Jun 2007, Prof Brian Ripley wrote:

> You may prefer the version now in R-devel: this goes slightly the other
> way in that it loads all the Suggests/Enhances packages and also a dummy
> compatibility package for platform differences.  Neither this nor the
> previous version can test the conditionalization is correct, as the code
> is analysed but no path through it is run.  It is entirely possible that
> the problems flagged are in code that can never be reached: this shows up
> dramatically in examples such as Hmisc with non-R code (for S3 or S4).

Splus 8 has a code-analysis routine called unresolvedGlobalReferences()
that helps identify potential problems when moving R code to Splus.
It is nowhere near as comprehensive as codetools::checkUsage().
However it does look for if statements of the form
   if (is.R())
and
   if (!is.R())
and won't analyze the R-only parts of the code marked by such
statements.  It would be nice if checkUsage() could do that as well.
unresolvedGlobalReferences() does not look for anything more
complicated than is.R() or !is.R() in the if statement, so it is
better to change things like
   if (is.R() || version$major>=9) { # R or future version of Splus
to use a more complicated arrangement of if statements,
each with a simpler condition in it.

To get really fancy, checkUsage() might also look for statements like
   if (require(pkgName))
and run them both ways, to make sure the non-pkgName code really
works when pkgName is not available.   This might overload the
nightly build machine, but would be useful for the developer.

----------------------------------------------------------------------------
Bill Dunlap
Insightful Corporation
bill at insightful dot com
360-428-8146

 "All statements in this message represent the opinions of the author and do
 not necessarily reflect Insightful Corporation policy or position."



[Rd] package check note: no visible global function definition (in functions using Tcl/Tk)
Bill Dunlap