Skip to content
Prev 200496 / 398503 Next

Where are usages like "== 2L" documented?

The word "integer" in the above sentence of the NumericConstants help
page is hyperlinked to the integer() function page.  There is then no
example or discussion of L there.
Yes, additional discussion of "L" would be very valuable.  I've had
several people ask me about usages, as this original poster did.
I think that increased use of L has outpaced updating of help entries.
Given that L is appearing in more places, I'd like to request additional
discussion of it and examples using it in help pages.
[1] "integer"
[1] "integer"

Since "integer" is the term often associated with this language construct,
that seems a natural place to say something about it, and direct users
to other appropriate help pages.

The help page for storage.mode() shows an example with "1i" in it,
could "1L" please also be added?  ("1.0" or "1." would also be useful.)

cex3 <- c("NULL","1","1:1","1i","list(1)","data.frame(x=1)",
  "pairlist(pi)", "c", "lm", "formals(lm)[[1]]",  "formals(lm)[[2]]",
  "y~x","expression((1))[[1]]", "(y~x)[[1]]",
  "expression(x <- pi)[[1]][[1]]")


The "L" language construct is often used in length checks such as
in the sample() function " if (length(x) == 1L ..."

The length() function help page discusses
" The default method currently returns an integer of length 1."
again with the "integer" hyperlinked to the integer() help page.
Since length() therefore can only assess integer lengths
from 0 to about 2^31 - 1 it would be helpful to discuss this
integer "L" construct and the range of values that can be expressed
with mode "integer" more fully somewhere in one of these help topics.
function (x, size, replace = FALSE, prob = NULL) 
{
    if (length(x) == 1L && is.numeric(x) && x >= 1) {
        if (missing(size)) 
            size <- x
        .Internal(sample(x, size, replace, prob))
    }
    else {
        if (missing(size)) 
            size <- length(x)
        x[.Internal(sample(length(x), size, replace, prob))]
    }
}
<environment: namespace:base>


Best
Steve McKinney