Why? Can you demonstrate any situations where its useful? Despite having my own facility for this I've found that over the years I have never used it.
On Sat, Mar 7, 2009 at 9:23 AM, <ivo...@gmail.com> wrote: > Gentlemen---these are all very clever workarounds, but please forgive me for > voicing my own opinion: IMHO, returning multiple values in a statistical > language should really be part of the language itself. there should be a > standard syntax of some sort, whatever it may be, that everyone should be > able to use and which easily transfers from one local computer to another. > It should not rely on clever hacks in the .Rprofile that are different from > user to user, and which leave a reader of end user R code baffled at first > by all the magic that is going on. Even the R tutorials for beginners should > show a multiple-value return example right at the point where function calls > and return values are first explained. > > I really do not understand why the earlier implementation of "multiple-value > returns" was deprecated. then again, I am a naive end user, not a computer > language expert. I probably would not even understand the nuances of syntax > ambiguities that may have arisen. (this is my shortcoming.) > > regards, > > /iaw > > > On Mar 7, 2009 4:34am, Wacek Kusnierczyk > <waclaw.marcin.kusnierc...@idi.ntnu.no> wrote: >> mark.braving...@csiro.au wrote: >> >> > >> >> >> The syntax for returning multiple arguments does not strike me as >> >> >> particularly appealing. would it not possible to allow syntax like: >> >> >> >> >> >> f= function() { return( rnorm(10), rnorm(20) ) } >> >> >> (a,d$b) = f() >> >> >> >> >> >> >> >> > >> >> > >> >> > FWIW, my own solution is to define a "multi-assign operator": >> >> > >> >> > '% >> > # a must be of the form '{thing1;thing2;...}' >> >> > a >> > e >> > stopifnot( length( b) == length( a)) >> >> > for( i in seq_along( a)) >> >> > eval( call( ' >> > NULL >> >> > } >> >> > >> >> >> >> you might want to have the check less stringent, so that rhs may consist >> >> of more values that the lhs has variables. or even skip the check and >> >> assign NULL to a[i] for i > length(b). another idea is to allow % >> be used with just one variable on the lhs. >> >> >> >> here's a modified version: >> >> >> >> '% >> a >> if (length(a) > 1) >> >> a >> if (length(a) > length(b)) >> >> b >> e >> for( i in seq_along( a)) >> >> eval( call( ' >> NULL } >> >> >> >> {a; b} % >> # a = 1; b = 2 >> >> a % >> # a = 3 >> >> {a; b} % >> # a = 5; b = NULL >> >> >> >> >> >> vQ >> ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel