[Rd] V2.9.0 changes [Sec=Unclassified]
Martin Maechler
maechler at stat.math.ethz.ch
Wed Jun 24 10:27:09 CEST 2009
>>>>> "TR" == Troy Robertson <Troy.Robertson at aad.gov.au>
>>>>> on Wed, 24 Jun 2009 16:35:29 +1000 writes:
TR> Yes, I had looked at R.oo, S4 and proto before beginning coding. I had initially assumed that S4 was an enhancement of or replacement to R.oo that was implemented at a lower level and had decided to go with the 'future' of OO in R.
TR> These assumptions were not necessarily correct.
>From the view of the R core team,
S4 *is* ``the future of OO in R''
But then, as professional statisticians, we should consider the
famous
>>> Prediction is very difficult, especially about the future <<
attributed to Physics Nobel Prize winner Niels Bohr.
---
Martin Maechler, ETH Zurich & R-core
TR> Troy
TR> Troy Robertson
TR> Database and Computing Support Provider
TR> Southern Ocean Ecosystems, ERM/Fish
TR> Australian Antarctic Division
TR> Channel Highway, Kingston 7050
TR> PH: 03 62323571
TR> Troy.Robertson at aad.gov.au
>> -----Original Message-----
>> From: Antonio, Fabio Di Narzo [mailto:antonio.fabio at gmail.com]
>> Sent: Tuesday, 23 June 2009 6:22 PM
>> To: Troy Robertson
>> Cc: r-devel at R-project.org
>> Subject: Re: [Rd] V2.9.0 changes [Sec=Unclassified]
>>
>> Not a direct answer to your question, but...
>> You might consider using the R.oo package, from H. Bengtsson. It's
>> very stable, written in pure R, and cleanly allows you to do
>> pass-by-reference OO programming, with no tricks.
>>
>> HTH,
>> af
>>
>> 2009/6/23 Troy Robertson <Troy.Robertson at aad.gov.au>:
>> > Hi all,
>> >
>> >
>> >
>> > Prefix: I am a frustrated Java coder in R.
>> >
>> >
>> >
>> > I am coding a medium sized ecosystem modelling program in R. I have
>> changed to using S4 objects and it has cost me an order of magnitude in
>> execution speed over the functional model. I cannot afford this penalty
>> and have found that it is the result of all the passing-by-value of
>> objects.
>> >
>> >
>> >
>> > I see that you can now safely inherit from environment in V2.9.0.
>> >
>> > That got me all excited that I would now be able to pass objects by
>> reference.
>> >
>> >
>> >
>> > But...
>> >
>> > That doesn't seem to be the case.
>> >
>> > It only seem that passing an environment which holds the object allows
>> for pass-by-reference and that passing an object which inherits from
>> environment doesn't.
>> >
>> > Why is this the case, either an object inherits the properties of its
>> parent or it doesn't.
>> >
>> > Has anyone else had a play with this? Or have I got it all wrong.
>> >
>> >
>> >
>> > I tried the below:
>> >
>> > ------------------------------------------------------------------------
>> -----------------
>> >
>> > setClass('foo', representation=representation(stuff='list',
>> bar='numeric'),
>> >
>> > prototype=list(stuff=list(), bar=0),
>> >
>> > contains='.environment')
>> >
>> >
>> >
>> > setGeneric('doit', function(.Object, newfoo='environment')
>> standardGeneric('doit'))
>> >
>> >
>> >
>> > setMethod('doit', 'foo', function(.Object, newfoo){newfoo at bar <- 10})
>> >
>> >
>> >
>> > z <- new('foo')
>> >
>> >
>> >
>> > z at stuff$x <- new('foo')
>> >
>> >
>> >
>> > doit(z,z at stuff$x)
>> >
>> >
>> >
>> > z at stuff$x at bar
>> >
>> >
>> >
>> > [1] 0
>> >
>> > ------------------------------------------------------------------------
>> ------------------
>> >
>> >
>> >
>> > Can anyone help with a better way of doing this.
>> >
>> > I'm trying to avoid all the indirection of packing and unpacking
>> environments for passing.
>> >
>> >
>> >
>> >
>> >
>> > Thanks heaps
>> >
>> > Troy
>> >
..............
>> --
>> Antonio, Fabio Di Narzo
>> Ph.D. student at
>> Department of Statistical Sciences
>> University of Bologna, Italy
TR> ___________________________________________________________________________
More information about the R-devel
mailing list