R-beta: Re: "as.numeric" `mode' and `cast' should be kept separate.

Z. Todd Taylor (Todd.Taylor@pnl.gov)
Wed, 03 Jun 1998 07:00:26 -0700

Date: Wed, 03 Jun 1998 07:00:26 -0700
From: Todd.Taylor@pnl.gov (Z. Todd Taylor)
Subject: R-beta: Re: "as.numeric" `mode' and `cast' should be kept separate.
To: r-help@stat.math.ethz.ch

Bill Venables <wvenable@attunga.stats.adelaide.edu.au> wrote:

[ snip ]

> I don't say this will appeal to everyone straight away, but I
> would even favour using a binary operator syntax for the
> assignment function form of the above replacement function, for
> example
> "%cast.as%" <- function(x, form) {
> 	storage.mode(x) <- deparse(substitute(form))
> 	x
> }
> Calls to .C would then take on such a striking form that it would
> be immediately noticed if something had been missed:
> 	result <- .C("some_flashy_C_thing",
> 		     x = my.x %cast.as% double,
> 		     i = my.eye %cast.as% integer,
> 		     oops = forgot.this.one,
> 		     value = z %cast.as% single)$value

I really like that idea!  But I have to nit-pick the suggested
implementation.  Instead of the deparse(substitute()) stuff,
just take a simple character string.  Else you can't do things

   x %cast.as% storage.mode(y)

Z. Todd Taylor
Pacific Northwest National Laboratory
Why is the 'last time' previous to this time?
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request@stat.math.ethz.ch