On Mon, Aug 31, 2009 at 10:00 AM, Duncan Murdoch<murd...@stats.uwo.ca> wrote:
> On 8/31/2009 11:50 AM, Mark Knecht wrote:
>>
>> On Mon, Aug 31, 2009 at 6:36 AM, Terry Therneau<thern...@mayo.edu> wrote:
>> <SNIP>
>>>
>>> The authors borrowed so much else from C, the semicolon would have been
>>> good too.
>>
>> <SNIP>
>>
>> I know real R coders will chuckle
>
> I'd say cringe, rather than chuckle.  This is going to make you waste a lot
> of time some day, when you stare and stare at code like Terry's and can't
> figure out what's wrong with it:
>
>        zed <- function(x,y,z) {
>               x + y
>                 +z;
>              }
>
> The value of the function is +z, not x+y+z, even though the C part of your
> brain made you type it that way and reads it as one statement in the body,
> not two.
>
> Duncan Murdoch
>

Oh, I completely agree.

Nominally I would have broken my rules for inserting semi-colons as
shown above. I should have done something more like this:

zed <- function(x,y,z) {
               x + y;
                 +z;
              }
;

but your point is completely correct. If I start forgetting that the
semi-colon is doing nothing then I'll cause myself problems. Also, if
I hot some case where the semi-colon serves a real purpose in R I'll
be totally confused, so this isn't a good thing to be doing. Not sure
I'll continue, but as I learn the language it's helped me see where
code lines end a bit better.

Thanks,
Mark

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to