[Rd] Patch proposal for R style consistency (concerning deparse.c)
Hervé Pagès
hpages at fhcrc.org
Thu May 2 21:09:21 CEST 2013
On 05/02/2013 05:26 AM, Terry Therneau wrote:
> I'll be the "anybody" to argue that
> } else {
> is an ugly kludge which you will never find in my source code. Yes,
> it's necessary at the command line because the parser needs help in
> guessing when an expression is finished, but is only needed in that
> case.
No, it's also needed wherever the if statement is at the top-level
(i.e. not nested within { ... }), in a package:
hpages at thinkpad:~$ R CMD INSTALL SomePackage
* installing to library
‘/home/hpages/R/R-3.0.0--disable-byte-compiled-packages/library’
* installing *source* package ‘SomePackage’ ...
** R
Error in parse(outFile) :
/home/hpages/svn/bioconductor/Rpacks/SomePackage/R/assignReads.R:8:1:
unexpected 'else'
7: }
8: else
^
ERROR: unable to collate and parse R files for package ‘SomePackage’
* removing
‘/home/hpages/R/R-3.0.0--disable-byte-compiled-packages/library/SomePackage’
or in a stand-alone script:
> source("somescript.R")
Error in source("somescript.R") : somescript.R:4:1: unexpected 'else'
3: }
4: else
^
It's invalid code. Period.
H.
> Since I can hardly imagine using else at the command line (that
> many correct characters in a row exceeds my typing skill) it's not an
> issue for me. I most certainly would not inflict this construction on my
> pupils when teaching a class, nor that any break of a long line has to
> be after "+" but not before, nor other crutches for the parser's sake.
> Let them know about the special case of course, but don't sacrifice good
> coding style the deficiency.
>
> That said, I am completely ambivalent to the result of deparse. Just
> throwing up an objection to the "purity" argument: things were beginning
> to sound a bit too bombastic :-).
>
> Terry T.
>
> On 05/02/2013 05:00 AM, r-devel-request at r-project.org wrote:
>> I want "} else {". Yihue wants "} else {". And I have not heard
>> anybody
>> say they prefer the other way, unless you interpret Duncan's comment
>> "that's nonsense" as a blanket defense of the status quo. But I don't
>> think
>> he meant that. This is a matter of style consistency and avoidance of
>> new
>> R-user confusion and error.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
--
Hervé Pagès
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024
E-mail: hpages at fhcrc.org
Phone: (206) 667-5791
Fax: (206) 667-1319
More information about the R-devel
mailing list