From m@ech|er @end|ng |rom @t@t@m@th@ethz@ch  Tue Aug  2 09:26:12 2022
From: m@ech|er @end|ng |rom @t@t@m@th@ethz@ch (Martin Maechler)
Date: Tue, 2 Aug 2022 09:26:12 +0200
Subject: [Rd] Should invisible() get signature x=NULL?
In-Reply-To: <02ae40ec-4824-7594-131f-b9cea33c8915@gmail.com>
References: <CAD7Bkx-H+-Xe=SFZbBE3Zgw89Dy--uA4nzcQO9U7obzHjSxeHg@mail.gmail.com>
 <02ae40ec-4824-7594-131f-b9cea33c8915@gmail.com>
Message-ID: <25320.53652.284203.674733@stat.math.ethz.ch>

>>>>> 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



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