From huber at ebi.ac.uk  Sat Feb 28 19:01:19 2009
From: huber at ebi.ac.uk (Wolfgang Huber)
Date: Sat, 28 Feb 2009 18:01:19 +0000
Subject: [Rd] Unexpected side effect of the ":::" operator on the value
 of isGeneric
In-Reply-To: <18857.8527.746773.902464@cmath-5.math.ethz.ch>
References: <49A58AA7.8030500@ebi.ac.uk>
	<18857.8527.746773.902464@cmath-5.math.ethz.ch>
Message-ID: <49A97BEF.60907@ebi.ac.uk>

Dear Martin

name masking is a separate issue, which I do not want to explore here.

If one accepts the notion that unrelated generics of the same name may
exist in different namespaces (user confusion aside, I don't see a
technical reason why one shouldn't), then I find the behaviour of R in
the below case puzzling: the value of "showMethods(something)" called
from the global environment depends on whether or not the expression
"package::something" has previously been evaluated. The value of
isGeneric(something) is different when called from top-level and when
called within showMethods.

Best wishes
 Wolfgang


PS1: I do apologize if this behaviour is intentional, and documented
somewhere. I would then be puzzled even more though.

PS2: My code example used ":::", and there are some vague warnings in
its man page that ":::" is "dangerous". The problem also occurs with "::".

------------------------------------------------------------------
Wolfgang Huber  EBI/EMBL  Cambridge UK  http://www.ebi.ac.uk/huber


28/02/2009 11:34 Martin Maechler scripsit
>>>>>> "Wolfi" == Wolfgang Huber <huber at ebi.ac.uk>
>>>>>>     on Wed, 25 Feb 2009 18:15:03 +0000 writes:
> 
>     Wolfi> Hi,
>     Wolfi> when running the following on a fresh R,
> 
> 
>     Wolfi> library("IRanges")
>     Wolfi> annotation
>     Wolfi> showMethods("annotation")
>     Wolfi> Biobase:::annotation
>     Wolfi> showMethods("annotation")
> 
> 
>     Wolfi> I get (see the "^^^^^" marked output at the bottom):
> 
> 
>     >> library("IRanges")
> 
>     Wolfi> Carico il pacchetto richiesto: 'IRanges'
> 
>     Wolfi> The following object(s) are masked from package:base :
> 
>     Wolfi> cbind,
>     Wolfi> order,
>     Wolfi> pmax,
>     Wolfi> pmax.int,
>     Wolfi> pmin,
>     Wolfi> pmin.int,
>     Wolfi> rbind,
>     Wolfi> rep.int,
>     Wolfi> table
> 
>     >> annotation
>     Wolfi> standardGeneric for "annotation" defined from package "IRanges"
> 
>     Wolfi> function (x, ...)
>     Wolfi> standardGeneric("annotation")
>     Wolfi> <environment: 0x1a302b0>
>     Wolfi> Methods may be defined for arguments: x
>     Wolfi> Use  showMethods("annotation")  for currently available ones.
> 
>     >> showMethods("annotation")
>     Wolfi> Function: annotation (package IRanges)
>     Wolfi> x="AnnotatedList"
> 
>     >> Biobase:::annotation
>     Wolfi> standardGeneric for "annotation" defined from package "Biobase"
> 
>     Wolfi> function (object)
>     Wolfi> standardGeneric("annotation")
>     Wolfi> <environment: 0x205cee0>
>     Wolfi> Methods may be defined for arguments: object
>     Wolfi> Use  showMethods("annotation")  for currently available ones.
> 
>     >> showMethods("annotation")
> 
>     Wolfi> Function "annotation":
>     Wolfi> <not a generic function>
>     Wolfi> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> 
>     Wolfi> It seems that the value of isGeneric("annotation"), when it is called
>     Wolfi> within showMethods, is FALSE, while it is TRUE when called outside.
> 
> Hi Wolfgang,
> 
> I have looked at the NAMESPACE files of the two packages  
> Biobase and IRanges, (the Bioconductor development version in SVN),
> and I think the problem might result from the fact
> that IRanges  does export the  annotation  generic, does not 
> exportMethods( ...  annotation ...).
> 
> OTOH,  Biobase  exportMethods(  annotation ) only [but not the generic].
> and then both packages do not at all mention each other,
> neither in DESCRIPTION nor NAMESPACE.
> 
> Either you are talking about conceptually the same generic
> annotation(); in that case one package needs to import*() it
> from the other, 
> or then you have two completely different animals, but then
> (masking) problems are unavoidable 
> -- in spite of the fact that I vaguely remember that some
>    Bioconductor developers repeatedly emphasize that these
>    problems are not problems for them
>  
> Martin
> 
>     >> sessionInfo()
>     Wolfi> R version 2.9.0 Under development (unstable) (2009-02-25 r48007)
>     Wolfi> x86_64-unknown-linux-gnu
> 
>     Wolfi> locale:
>     Wolfi> LC_CTYPE=it_IT.UTF-8;LC_NUMERIC=C;LC_TIME=it_IT.UTF-8;LC_COLLATE=it_IT.UTF-8;LC_MONETARY=C;LC_MESSAGES=it_IT.UTF-8;LC_PAPER=it_IT.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=it_IT.UTF-8;LC_IDENTIFICATION=C
> 
>     Wolfi> attached base packages:
>     Wolfi> [1] stats     graphics  grDevices utils     datasets  methods   base
> 
>     Wolfi> other attached packages:
>     Wolfi> [1] IRanges_1.1.40
> 
>     Wolfi> loaded via a namespace (and not attached):
>     Wolfi> [1] Biobase_2.3.10
> 
> 
> 
>     Wolfi> Best wishes
>     Wolfi> Wolfgang
> 
>     Wolfi> ------------------------------------------------------------------
>     Wolfi> Wolfgang Huber  EBI/EMBL  Cambridge UK  http://www.ebi.ac.uk/huber
> 
>     Wolfi> ______________________________________________
>     Wolfi> R-devel at r-project.org mailing list
>     Wolfi> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Unexpected side effect of the ":::" operator on the value of isGeneric
Wolfgang Huber