From Troy.Robertson at aad.gov.au  Wed Jun 24 08:35:29 2009
From: Troy.Robertson at aad.gov.au (Troy Robertson)
Date: Wed, 24 Jun 2009 16:35:29 +1000
Subject: [Rd] V2.9.0 changes [Sec=Unclassified]
In-Reply-To: <b0808fdc0906230121n243072fbrd62cbe1614d13b50@mail.gmail.com>
Message-ID: <42C7503E0B99F248B06BC65E7D2B4E020122C50FB22C@EX2K7-CCR.AAD.GOV.AU>

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.

These assumptions were not necessarily correct.

Troy

Troy Robertson
Database and Computing Support Provider
Southern Ocean Ecosystems, ERM/Fish
Australian Antarctic Division
Channel Highway, Kingston 7050
PH: 03 62323571
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
> >
> >
> >
> >
> >
> > Troy Robertson
> >
> > Database and Computing Support Provider
> >
> > Southern Ocean Ecosystems, ERM/Fish
> >
> > Australian Antarctic Division
> >
> > Channel Highway, Kingston 7050
> >
> > PH: 03 62323571
> >
> > Troy.Robertson at aad.gov.au
> >
> >
> >
> >
> >
> __________________________________________________________________________
> _
> >
> >    Australian Antarctic Division - Commonwealth of Australia
> > IMPORTANT: This transmission is intended for the addressee only. If you
> are not the
> > intended recipient, you are notified that use or dissemination of this
> communication is
> > strictly prohibited by Commonwealth law. If you have received this
> transmission in error,
> > please notify the sender immediately by e-mail or by telephoning +61 3
> 6232 3209 and
> > DELETE the message.
> >        Visit our web site at http://www.antarctica.gov.au/
> >
> __________________________________________________________________________
> _
> >
> >        [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
>
>
> --
> Antonio, Fabio Di Narzo
> Ph.D. student at
> Department of Statistical Sciences
> University of Bologna, Italy
___________________________________________________________________________

    Australian Antarctic Division - Commonwealth of Australia
IMPORTANT: This transmission is intended for the addressee only. If you are not the
intended recipient, you are notified that use or dissemination of this communication is
strictly prohibited by Commonwealth law. If you have received this transmission in error,
please notify the sender immediately by e-mail or by telephoning +61 3 6232 3209 and
DELETE the message.
        Visit our web site at http://www.antarctica.gov.au/
___________________________________________________________________________



[Rd] V2.9.0 changes [Sec=Unclassified]
Troy Robertson