R-alpha: more 'eval' bugs \\ typeof(.) <-> storage.mode(.) <-> mode(.)

Martin Maechler (maechler@stat.math.ethz.ch)
Tue, 26 Mar 96 16:12:28 +0100


Date: Tue, 26 Mar 96 16:12:28 +0100
Message-Id: <9603261512.AA01326@>
From: Martin Maechler <maechler@stat.math.ethz.ch>
To: R-testers@stat.math.ethz.ch
Subject: R-alpha: more 'eval' bugs \\  typeof(.)  <->  storage.mode(.)  <->  mode(.)

Hmm, 0.3 really broke quite a few things  ....
It's again the  eval(.) 
	[-- AFTER applying Ross's patch which makes 'source(.)' work ..]

	storage.mode(x) <- "integer"

also breaks (which breaks several other functions, e.g. 'qr');
storage.mode is defined in  ...../src/rrc/mode  as

	"storage.mode<-" := eval(as.name("mode<-"))

And this eval breaks with
	"Error: attempt to apply non-function"
it works in 0.2.

-----------------------------------------------------------------
More generally:

There is some  confusion  about  these functions;
actually there are 5 (FIVE) functions, currently:


1) typeof	   : primitive  (defined ./src/main/coerce.c)
2) mode
3) mode<-
4) storage.mode
5) storage.mode<-

2-5) are all defined in  src/rrc/mode,	where 

  mode(x) is a function of  typeof(x) alone,

  mode<-  calls the corresponing  "as.MODE" function,

  storage.mode is made 'synonymous' with mode
	storage.mode := mode
	"storage.mode<-" := eval(as.name("mode<-"))

-------
The 'bogous' things are seen here

x <- pi
i <- 7
ii <- i

storage.mode(ii) #-> "numeric";  I'd rather see 'integer' or 'real' ...
storage.mode(ii) <- "integer"  #- well, ..
#-> Error: attempt to apply non-function

mode(ii) <- "integer"  #- well, no error message

storage.mode(ii) #-> "numeric", still
typeof(ii) #-> "integer"


invisible(lapply(list(x=x,i=i,ii=ii, i1 = ii %/% ii), function(x) 
		 cat("x=", x, " typeof=", typeof(x),";  mode=", mode(x),"\n")))

---------------------------
My conclusion:

	storage.mode(.)  should really  be the same as  typeof(.)
			 instead of  mode(.).
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-