[R] R is GNU S, not C.... [was "how to get or store ....."]

Liaw, Andy andy_liaw at merck.com
Tue Dec 6 19:04:52 CET 2005


From: Martin Maechler
> 
> >>>>> "P" == P Ehlers <ehlers at math.ucalgary.ca>
> >>>>>     on Tue, 06 Dec 2005 08:35:07 -0700 writes:
> 
>     P> vincent at 7d4.com wrote:
> 
>     >> Martin Maechler a écrit :
>     >> 
>     >> 
>     >>> please, please,  these trailing ";"  are  *so* ugly.
>     >>> This is GNU S, not C (or matlab) !
>     >>> 
>     >>> but I'll be happy already if you could
>     >>> drop these ugly empty statements at the end of your lines...
>     >> 
>     >> 
>     >> May I disagree ?
>     >> I find missing ";" at end of lines *so* ugly.
>     >> Ugly/not ugly depends on our observer's eyes.
>     >> From my programmer point of view, I prefer to mark
>     >> clearly the end of the lines.
>     >> In many languages, it's safer to do it this way,
>     >> and I thank the R developers to permit it.
>     >> (in my opinion, it should even be mandatory).
>     >> (By the way, marking the end of lines with a unique symbol
>     >> makes also the job easier for the following treatment.)
>     >> And yes, I'm also a C programmer ;-)
>     >> 
>     >> > {and I have another chain of argments why   "<-" is so more
>     >> > expressive than "="
>     >> 
>     >> Why "<-" seems better than "=" is also quite mysterious for me.
>     >> There was a discussion about this point recently I think.
>     >> I believe in 99% of cases it's more for historical reason
>     >> (and perhaps also for some "snob" reasons).
>     >> 
>     >> I am not at all a 20 years experienced R programmer, but I have
>     >> written several hundreds of R lines those 6 last months,
>     >> and until today didn't get any problem using "=" 
> instead of "<-".
>     >> 
>     >> But I'll read your chain of arguments with interest.
> 
> 
>     P> Well, I'll have to disagree a bit. While I don't care so much
>     P> about trailing ";" (as long as it does not become mandatory),
>     P> I don't like the use of "=" for assignment and that's 
> definitely
>     P> NOT for "snob" reasons, whatever those are. I just 
> think code is
>     P> *much* easier to read if assignment is distinguished from
>     P> argument settings.
> 
> Thank you, Peter.  Indeed, this is exactly the main of my arguments:
> Since "=" is used quite often in S for argument setting in
> function calls, *additionally* using "<-" for assignment is
> more expressive. 
> Also, e.g., a2ps (a nice 'ASCII' to PostScript converter), comes
> {at least on Debian Linux} preconfigured for R, and uses nice
> typesetting for "<-"; similarly for ESS.
> OTOH, it's pretty hard to correctly markup and differentiate
> those "=" which are assignments from those which are function.
> argument settings.
> 
>     P> Peter Ehlers
> 
> [But really, I'm more concerned and quite bit disappointed by
>  the diehard ";" lovers]
> 
> Martin Maechler

Matlab also allows both with and without ";", but I guess most people learn
quickly what the preferred way is:  Without ";", Matlab prints the output of
commands, including assignments; e.g., if you assign a 1e5-row matrix to
something, and didn't terminate the line with ";", Matlab will print that
matrix to the console.

Personally, having the extraneous ";" doesn't bother me nearly as much as
not indenting the code properly or leave spaces around operators.  I don't
use them, because I seldom have difficulty knowing when a statement is
suppose to end (given the code is properly indented).  Those who use Python
would know quite well, too, I guess.  For those who insist on having ";", I
guess they will never get the point of something like Python (or even
Fortran...).

Andy




More information about the R-help mailing list