[Rd] Should invisible() get signature x=NULL?

Martin Maechler m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Tue Aug 2 09:26:12 CEST 2022


>>>>> Duncan Murdoch 
>>>>>     on Mon, 1 Aug 2022 20:08:53 -0400 writes:

    > On 01/08/2022 6:27 p.m., Michael Chirico via R-devel
    > wrote:
    >> I think most experienced R users are familiar with
    >> return(invisible()) being used as shorthand for
    >> return(invisible(NULL)).

    > I'm not sure that's true... the R sources themselves are
    > inconsistent about using invisible() vs invisible(NULL).

Well, they *are* identical in what they return, but to me there *is* a
stylistic difference:  The latter emphasizes the return value to
be NULL.

    >> However, this NULL default is not documented anywhere --
    >> we have to dive into src/main/print.c:do_invisible to
    >> source this behavior.
    >> 
    >> Is this lack of documentation intentional? Otherwise,
    >> should the signature be updated to reflect this default?
    >> 
    >> invisible <- function(x = NULL) .Primitive("invisible")
    >> 
    >> Otherwise, should this default be mentioned in ?invisible
    >> ?

    > But documenting it seems wise.

    > Duncan Murdoch

I prefer to agree with Michael that the "fake" argument list (*)
should be updated to 'x = NULL'.

*) Primitive functions have no formal arguments.  We have
 provided artificially constructed formal arguments mainly for
 printing, only "relatively recently".
 E.g., in R 2.0.0, we still had

> invisible
.Primitive("invisible")


Martin

--
Martin Maechler
ETH Zurich  and  R Core team



More information about the R-devel mailing list