[Rd] Good practice for naming classes, builders, attributes, getters/setters for object composition

2015-11-20 Thread Julien Idé
Hey everyone,

I am developing a package and I am wondering if there is a good practice
for naming classes, builders, attributes getters and setters when dealing
with object composition. I know that it is usually a good practice to give
to the builder the same name as the class and, if possible, to avoid to use
upper case letters. My problem is that, when I build an object containing
an other object (of an other class), at the end my getters can have the
same name as my builders. Here is an example.

Lets define a first class "bonds" to store atomic bonds information:
bonds <- function(ind1, ind2, order){
  obj <- data.frame(ind1 = ind1, ind2 = ind2, order = order)
  class(obj) <- c("bonds", class(obj))
  return(obj)
}

Now I when to define an other class to store atomic properties.
As atoms can be bonded to each other, I add a "bonds" attribute which is of
class "bonds".
atoms <- function(symb, mass, charge, bonds){
  obj <- data.frame(symb = symb, mass = mass, charge = charge)
  attr(obj, "bonds") <- bonds
  class(obj) <- c("atoms", class(obj))
  return(obj)
}
Now if I when to get the "bonds" attribute of an "atoms" object, I have to
define:
bonds <- function(x)
  UseMethod("bonds")

bonds.atoms <- function(x)
  attr(x, "bonds")

As you can see my getter has the same name as the builder for class "bonds".
Any suggestion?

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Good practice for naming classes, builders, attributes, getters/setters for object composition

2015-11-20 Thread Michael Lawrence
On Fri, Nov 20, 2015 at 12:39 AM, Julien Idé  wrote:
> Hey everyone,
>
> I am developing a package and I am wondering if there is a good practice
> for naming classes, builders, attributes getters and setters when dealing
> with object composition. I know that it is usually a good practice to give
> to the builder the same name as the class and, if possible, to avoid to use
> upper case letters. My problem is that, when I build an object containing
> an other object (of an other class), at the end my getters can have the
> same name as my builders. Here is an example.
>
> Lets define a first class "bonds" to store atomic bonds information:
> bonds <- function(ind1, ind2, order){
>   obj <- data.frame(ind1 = ind1, ind2 = ind2, order = order)
>   class(obj) <- c("bonds", class(obj))
>   return(obj)
> }
>
> Now I when to define an other class to store atomic properties.
> As atoms can be bonded to each other, I add a "bonds" attribute which is of
> class "bonds".
> atoms <- function(symb, mass, charge, bonds){
>   obj <- data.frame(symb = symb, mass = mass, charge = charge)
>   attr(obj, "bonds") <- bonds
>   class(obj) <- c("atoms", class(obj))
>   return(obj)
> }
> Now if I when to get the "bonds" attribute of an "atoms" object, I have to
> define:
> bonds <- function(x)
>   UseMethod("bonds")
>
> bonds.atoms <- function(x)
>   attr(x, "bonds")
>
> As you can see my getter has the same name as the builder for class "bonds".
> Any suggestion?
>

I would definitely distinguish constructors from accessors somehow. In
Bioconductor, we use capitalized class names, and thus capitalized
constructors. If you don't like capital letters, you will need to
think of something else ;) Like new_bonds(), get_bonds(), etc.

Btw, bonds are not intrinsic to atoms, but rather molecules. You
should consider a molecule class.

> [[alternative HTML version deleted]]
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

[Rd] R-devel no longer supports Ubuntu 14.04 LTS (insufficient PCRE version)

2015-11-20 Thread Sebastian Meyer
Since yesterday's r69662, R no longer ./configure[s] on a standard
Ubuntu 14.04.3 installation, which ships with PCRE 8.31
(http://packages.ubuntu.com/trusty-updates/libpcre3-dev)

I get:

> checking if PCRE version >= 8.32, < 10.0 and has UTF-8 support... no
> checking whether PCRE support suffices... configure: error: pcre library and 
> headers are required

Are there any workarounds for this except for manually compiling and
installing a more recent version of PCRE from source?

Thanks!

Sebastian


-- 
University of Zurich
Sebastian Meyer
Epidemiology, Biostatistics and Prevention Institute
(Department of Biostatistics)
Hirschengraben 84
CH-8001 Zürich
Tel: +41 44 63-45485
Fax: +41 44 63-44386
www.biostat.uzh.ch
sebastian.me...@uzh.ch

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] R-devel no longer supports Ubuntu 14.04 LTS (insufficient PCRE version)

2015-11-20 Thread Dirk Eddelbuettel

On 20 November 2015 at 16:14, Sebastian Meyer wrote:
| Since yesterday's r69662, R no longer ./configure[s] on a standard
| Ubuntu 14.04.3 installation, which ships with PCRE 8.31
| (http://packages.ubuntu.com/trusty-updates/libpcre3-dev)
| 
| I get:
| 
| > checking if PCRE version >= 8.32, < 10.0 and has UTF-8 support... no
| > checking whether PCRE support suffices... configure: error: pcre library 
and headers are required
| 
| Are there any workarounds for this except for manually compiling and
| installing a more recent version of PCRE from source?

The technical term is 'backport'. You could try and see if someone has taken
the (Debian or Ubuntu) source package for pcre (current, ie >= 8.32) and
created a package on launchpad.net in a PPA.

Otherwise it is pretty easy to do yourself ... and if you just wait a little
Michael will have to do it anyway to get R 3.3 built for 14.04.

(I was just bitten yesterday by R 3.2.2 re-built for Ubuntu 12.04 [ as used
by Travis ] not having libcurl capabilities. But that may well be a more
involved library than pcre so I left it at that.)

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R-devel no longer supports Ubuntu 14.04 LTS (insufficient PCRE version)

2015-11-20 Thread Prof Brian Ripley

I think you have it backwards: Ubuntu 14.04 does not support R-devel 

PCRE 8.32 is 3 years old, so Ubuntu 14.04 shipped an already quite old 
version 19 months ago.


R has long said that its requirement was

   PCRE (version 8.10 or later, preferably 8.32 or later)

and 8.32 is indeed preferable: the aim is that all the current PCRE 
regex syntax be usable on all platforms.


Given that you appear to be installing R from the sources, PCRE is no 
more difficult to install from source 


R-devel is 'under development' and months off release: if this proves to 
be too restrictive we can postpone the aim to 3.4.x.



On 20/11/2015 15:14, Sebastian Meyer wrote:

Since yesterday's r69662, R no longer ./configure[s] on a standard
Ubuntu 14.04.3 installation, which ships with PCRE 8.31
(http://packages.ubuntu.com/trusty-updates/libpcre3-dev)

I get:


checking if PCRE version >= 8.32, < 10.0 and has UTF-8 support... no
checking whether PCRE support suffices... configure: error: pcre library and 
headers are required


Are there any workarounds for this except for manually compiling and
installing a more recent version of PCRE from source?

Thanks!

Sebastian





--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel