On Tue, Aug 28, 2012 at 4:55 PM, Sam Steingold <sds at gnu.org> wrote:
* R. Michael Weylandt <zvpunry.jrlynaqg at tznvy.pbz> [2012-08-28 13:45:35 -0500]:
always you shouldn't need manual garbage collection.
my observation is that gc in R sucks.
(it cannot release small objects).
this is not specific to R; ocaml suffers too.
That may be (I don't know enough about gc's to really say one way or
another), but if I remember correctly, allocation triggers gc, so
manual triggering shouldn't be too important. In my experience, the
one point I've needed it was after freeing multiple very large objects
when hitting memory limits. Rewriting that code to use functions
rather than as one long imperative slog was a real performance win.
Note that if you are compiling locally, you can modify the gc
parameters (frequency of various sweeps) for different performance
characteristics -- grep src/main/memory.c for "Tuning Constants" and
the lines that follow.
since a loop doesn't define its own scope like some languages (a
practice that always seemed strange to me),
every level of indentation has its own scope.
seems reasonable.
I guess I see something like
for(i in 1:2){
f(i)
}
as little more than short hand for
f(1)
f(2)
rather than as something "more meaningful". I suppose you're thinking
of something like Ruby blocks here? Those correspond more closely to
anonymous functions in my mind. (scope wise)
Certainly, "to each his own" applies here.