[R] I don't understand this

Richard A. O'Keefe ok at cs.otago.ac.nz
Tue Sep 2 08:21:43 CEST 2003


I asked what 
> x <- NULL
> (if (TRUE) names else dim)(x) <- 27
is *supposed* to do.

Professor Brian Ripley basically gave me the answer I wanted:
it isn't *supposed* to do anything.  However, he went on to say

	And for R you have the source code, and a `R Language Definition'.
	
My original message made it clear that I had read the R documentation.
I am very favourably impressed by it; compared with many commercial
systems it is *superb*.  However, the R Language Definition is not
finished yet and does not discuss assignment at length.  In fact,
remarks on assignment are scattered thinly throughout the text, at
least one appears to have "right" when it means "left".  That's OK;
it doesn't claim to be finished documentation, but it does mean that
some questions cannot as yet be answered by reading it.

As for the code (src/main/eval.c), it tells you want DOES happen (if you
are considerably more familiar with R internals than I am yet), but with
R's characteristic paucity of comments, it says nothing about what is
*supposed* to happen.

By the way, is anyone else worried about this code:

    static SEXP applydefine(SEXP call, SEXP op, SEXP args, SEXP rho)
    {
	...
=======>char buf[32];
	...
	while (isLanguage(CADR(expr))) {
===========>sprintf(buf, "%s<-", CHAR(PRINTNAME(CAR(expr))));
	    tmp = install(buf);

A similar buffer-overrun in Windows RTF boxes led to a security
vulnerability.

To put it another way, it was a serious question for a serious reason,
and I _had_ done my homework, but I have a really hard time reading the
R sources.




More information about the R-help mailing list