[R] assigning from multiple return values

Peter Dalgaard p.dalgaard at biostat.ku.dk
Wed Jun 23 22:23:43 CEST 2004


"Liaw, Andy" <andy_liaw at merck.com> writes:

> My $0.02:
> 
> If Jack feels that the fact that functions usually return a single list, and
> one needs to access the components of the list separately, is somehow
> hideous, then I'd rather suggest that R is perhaps the wrong language for
> him.
> 
> To me the suggested `workarounds' are by far much more hideous...  They turn
> perfectly tranparent code into...  gee, I don't even know how to begin
> describing them...

I'm not sure that the idea of multiple assignment as such is all that
horrid. Other languages have them and it's actually kind of fun to see
if you can come up with a neat implementation. 

However, Gabor is definitely on the wrong track with list()<- It is
the kind of thing that looks like a good idea initially, but if you
think things through from a consistency viewpoint, you realize that it
doesn't quite make sense. Replacement functions are just that -
replacement functions. They logically require that there is an object
within which there is something to replace.


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list