From k@@perd@n|e|h@n@en @end|ng |rom gm@||@com  Tue Jun 13 20:03:08 2023
From: k@@perd@n|e|h@n@en @end|ng |rom gm@||@com (Kasper Daniel Hansen)
Date: Tue, 13 Jun 2023 14:03:08 -0400
Subject: [Rd] codetools wrongly complains about lazy evaluation in S4
 methods
In-Reply-To: <2cde2aab-8491-2f99-657e-ecb41ceda039@gmail.com>
References: <2cde2aab-8491-2f99-657e-ecb41ceda039@gmail.com>
Message-ID: <CAC2h7uu_8m=xC7KcB1i_uk=WW8bDvx4P7ACSPOp-s1PK=1nGQg@mail.gmail.com>

On Sat, Jun 3, 2023 at 11:51?AM Mikael Jagan <jaganmn2 at gmail.com> wrote:

> The formals of the newly generic 'qr.X' are inherited from the non-generic
> function in the base namespace.  Notably, the inherited default value of
> formal argument 'ncol' relies on lazy evaluation:
>
>      > formals(qr.X)[["ncol"]]
>      if (complete) nrow(R) else min(dim(R))
>
> where 'R' must be defined in the body of any method that might evaluate
> 'ncol'.
>

Perhaps I am misunderstanding something, but I think Mikael's expectations
about the scoping rules of R are wrong.  The enclosing environment of ncol
is where it was _defined_ not where it is _called_ (apologies if I am
messing up the computer science terminology here).

This suggests to me that codetools is right.  But a more extended example
would be useful. Perhaps there is something special with setOldClass()
which I am no aware of.

Also, Bioconductor has 100s of packages with S4 where codetools works well.

Kasper

	[[alternative HTML version deleted]]



[Rd] codetools wrongly complains about lazy evaluation in S4 methods
Kasper Daniel Hansen