Gabor Grothendieck wrote: > > I've provided an argument against it and no one has provided one > for it. The so-called identical code Ivo showed was not identical > and, in fact, was flawed.
no, you're wrong. you think of the part where ivo shows what he'd like to have; the example i was referring to was almost identical with yours, except for the explicit return and '=' used for assignment. > Your first/last example could be > written: > > f <- function() letters > L <- structure(f()[1:2], names = c("first", "last")) > indeed, but: - this still does not allow one to use the names directly, only as L$first etc., with the syntactic and semantic (longer lookup times) penalty; - using structure you add yet another source of performance penalty; a quick naive benchmark hints that it doubles the time elapsed if the returned list is inaccessible otherwise, and adds one order of magnitude if the list has to be copied: f1= function() as.list(letters) f2 =local({ letters = as.list(letters); function() letters }) source('http://rbenchmark.googlecode.com/svn/trunk/benchmark.r') benchmark(replications=10000, columns=c('test', 'elapsed'), 'f1 direct'=f1(), 'f1 structure'=structure(f1(), names=letters), 'f2 direct'=f2(), 'f2 structure'=structure(f2(), names=letters)) # test elapsed # 1 f1 direct 0.171 # 2 f1 structure 0.693 # 3 f2 direct 0.048 # 4 f2 structure 0.594 instead of a syntactically (and semantically, if done appropriately) clean solution: c(a, b) = f()[1,3] # work with a and b you offer a glut: l = structure(f()[1,3], names=c('a', 'b')) # work with l$a and l$b > or one could define a function to do that without having > to modify the language. Given the relative infrequency > of this it hardly seems to merit a language feature. > infrequency of what? of people's inventing ugly hacks to get arround the inability to capture multiple return values directly? sure, this is a good argument against having someone do the job, but is it a good argument against having the feature in the language? vQ ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel