[Rd] dim(a <- ...) sets invisible flag erronously (PR#587)
Prof Brian Ripley
Prof Brian Ripley <ripley@stats.ox.ac.uk>
Mon, 10 Jul 2000 14:36:51 +0100 (BST)
> Date: Fri, 30 Jun 2000 20:15:51 +0200 (MET DST)
> From: maechler@stat.math.ethz.ch
> To: r-devel@stat.math.ethz.ch
> Subject: [Rd] dim(a <- ...) sets invisible flag erronously (PR#587)
> CC: R-bugs@biostat.ku.dk
> X-Loop: R-bugs@biostat.ku.dk
>
> {Nothing really harmful; R 1.1.0}
>
> dim(.) sets (or doesn't clear) the ``invisible flag'' for printing in
> certain circumstances:
>
> > dim(a <- cbind(1))
> >
>
> does *not* print as it should :
>
> > dim(a)
> [1] 1 1
This is nothing to do with dim: any function will do this.
> foo <- function(x) x
> foo(a <- cbind(1))
It happens because the way invisible is implemented is different in R and S:
in S there is a .Auto.print var in frame 1, and in R there is a global
variable R_visible, so anything during the evaluation that unsets the
flag will ensure that the result is invisible.
I don't see how to avoid this without checking the `depth' in the evaluation
pretty carefully (and R's semantics differ from those of S in that
braced expressions do not generate a frame).
Is this worth fixing? print(.Last.value) works all the time, and perhaps
you might be persuaded not to write code that uses assignments as arguments?
> ---
>
> Question to the real "hackers" :
>
> How can I check this using R code alone (not using files),
> i.e. (how) can I ask an R expression if its ``invisible flag'' is set or not ?
>
> {help(invisible) doesn't help here}.
>
> Maybe one would want an
>
> is.invisible(.)
>
> function?
There seems to be an unused internal function do_visibleflag in print.c.
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._