[R] R as a programming language

Gabor Grothendieck ggrothendieck at gmail.com
Thu Nov 8 21:34:11 CET 2007


On Nov 8, 2007 3:16 PM, Jan T. Kim <jtk at cmp.uea.ac.uk> wrote:
> On Thu, Nov 08, 2007 at 01:35:34PM -0500, Duncan Murdoch wrote:
> > On 11/8/2007 1:26 PM, Barry Rowlingson wrote:
> > > hadley wickham wrote:
> > >
> > >> You're assuming an automatic cast from numbers into strings?  What if
> > >> a + "4" threw an error?
> > >
> > >   What's wrong with commas anyway when using cat():
> > >
> > >   > cat("x is ",x,' and y is ',y,'\n',sep='')
> > >   x is 1 and y is 2
> >
> > Nothing wrong when using cat(), but we sometimes need to compute strings
> > when we aren't using cat().
> >
> > >   and there's always sprintf() for those moments when you want neat
> > > formatting.
> >
> > That's good when you want good control over the formatting, but it
> > doesn't tend to be all that readable, with the variables all listed at
> > the end, instead of in between the bits of string.
>
> I'm probably saying the obvious but paste() can be used like cat() in
> the example above to obtain a string rather than to output it.
>
> Personally, I've come to prefer the printf style with the format string
> and the data to be formatted nicely separated, but perhaps I've just
> been programming in C / Python / Java too long...
>
> > >   Is it just me who thinks it's odd that in a language that is umpteen
> > > years old we are still discussing the fundamentals of what essentially
> > > makes up the 'hello world' example?
> >
> > Maybe.
>
> It seems to me that there are good reasons to discuss issues about the
> language (from time to time, anyway).
>
> What I'd like to see in R are:
>
>    (1) References. These have a more fundamental role than just saving
>      memory (by avoiding unnecessary copying of parameter values etc.)
>      in enabling programmers to achieve a higher level of representational
>      consistency: Each object in the problem domain should ideally
>      be represented by one object in a program, and that is currently
>      difficult and sometimes impossible to realise in R -- it's not
>      possible to distinguish equality and identity, as e.g. in Java
>      ("equals()" vs "==") or Python ("==" vs "is").

Environments and proto objects (in package proto) support object
identity already.



More information about the R-help mailing list