[Rd] classed

Telford Tendys telford@progsoc.uts.edu.au
Fri, 15 Sep 2000 15:00:52 +1100

On Thu, Sep 14, 2000 at 10:31:26AM -0400, Paul Gilbert wrote:
> classed <- function (x, cls)
> {
>     class(x) <- cls
>     x
> }
> The function is useful not so much because it saves a line of code
> in other functions, but because I think it encourages a cleaner, easier to read
> style.

Just to add my 2c, I don't believe it is cleaner to hide assignment
statements inside functions without some reasonably sensible reason to
do so. When I see something like:

	y <- wibble( x, "foo" );

I would expect `x' not to change. Now OK this isn't a watertight rule
(nothing ever is) but little functions containing hidden assignment
statements are usually confusing to a reader not already familiar
with the code.

	- Tel

r-devel 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-devel-request@stat.math.ethz.ch