On Mon, Jul 28, 2008 at 6:33 AM, Prof Brian Ripley <[EMAIL PROTECTED]>wrote:

> On Mon, 28 Jul 2008, Felix Andrews wrote:
>
>  Hi R-devel
>>
>> I use the packages RGtk2 and cairoDevice. The cairoDevice package has
>> a few stand-alone functions, plus "asCairoDevice" which depends on
>> RGtk2 and calls require(RGtk2). So cairoDevice lists RGtk2 under
>> "Suggests" in the DESCRIPTION file. It can not Import RGtk2 because
>> that would force all users to install RGtk2.
>>
>> The upshot of this is, if you *import* the RGtk2 namespace into
>> another package and then call asCairoDevice(), RGtk2 is attached to
>> the user's search path. That is significant because RGtk2 exports a
>> large number of objects: -- 7476 to be exact -- which can clog up
>> things like help.search and autocompletion.
>>
>> What is the recommended solution? Could asCairoDevice call
>> loadNamespace rather than require?
>>
>
> The code is
>
>  asCairoDevice
>>
> function (widget, pointsize = 10)
> {
>    if (!require("RGtk2"))
>        stop("asGtkDevice requires the RGtk package")
>    if (!inherits(widget, "GtkDrawingArea") && !inherits(widget,
>        "GdkDrawable")) {
>        stop("Object being used as a Cairo Device must be a GtkDrawingArea
> or GdkDrawable")
>    }
>    .Call("do_asCairoDevice", widget, as.numeric(pointsize),
>        PACKAGE = "cairoDevice")
> }
>
> Note that the stop() message is wrong (wrong function name, wrong package)
> and seems most likely an error.  But why not ask the package author?
>

I can't remember putting this in there, but anyway it's pointless, as RGtk2
must already be loaded if someone is going to be passing a widget to the
function. Nor does the function use any RGtk2 symbols.

So that's an easy fix.

Thanks,
Michael


>
> The normal solution is to use :: to load functions from a name space
> required only in rarely used functions in your package.
>
> --
> Brian D. Ripley,                  [EMAIL PROTECTED]
> Professor of Applied Statistics,  
> http://www.stats.ox.ac.uk/~ripley/<http://www.stats.ox.ac.uk/%7Eripley/>
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to