[Rd] OT: Reason/history behind ## notation for comments?

Martin Maechler maechler at stat.math.ethz.ch
Thu Sep 23 13:52:05 CEST 2010


>>>>> "LG" == Laurent Gatto <laurent.gatto at gmail.com>
>>>>>     on Wed, 22 Sep 2010 08:33:20 +0100 writes:

    LG> For what concerns emacs users, the number of '#' has
    LG> different effects on the position of the comment. From
    LG> the ESS manual: 'By default, comments beginning with
    LG> ‘###’ are aligned to the beginning of the line. Comments
    LG> beginning with ‘##’ are aligned to the current level of
    LG> indentation for the block containing the
    LG> comment. Finally, comments beginning with ‘#’ are
    LG> aligned to a column on the right...'. I guess that ## is
    LG> the most wanted indentation for comments.

Yes, that's all correct.
(and Emacs+ESS being used quite a bit by some active R Core
 members, at least "historically")

One thing to add:
As most of you probably know, R was built using ideas and
concepts from Lisp (aka "LISP"), and (Emacs-)Lisp being emacs'
extension language, Emacs has always supported
auto-indenting/filling of comments---which in lisp start with a
";" --- using different indentation rules for ";", ";;", ";;;" ....
So it seems quite apt for R to continue this Lisp convention.
Given the Lisp decent, this tradition is probably quite an old one in
(academic) programming history. 

Martin Maechler,
ETH Zurich (and R Core)


    LG> Best wishes,

    LG> Laurent

    LG> On 22 September 2010 07:26, Henrik Bengtsson
    LG> <hb at stat.berkeley.edu> wrote:
    >> Off topic, but since I've observe both styles, does
    >> anyone know the history behind/reason for using ##
    >> instead of a single # to start comments in R.  I know
    >> some editors do this by default.  Is it because in C it
    >> is easier to distinguish (search/replace/...) comments
    >> from C preprocessor directives such as #include, and
    >> that's became a de facto standard elsewhere?
    >> 
    >> /Henrik
    >> 
    >> PS. I don't want to get into a debate on what's the best
    >> style.
    >> 
    >> ______________________________________________
    >> R-devel at r-project.org mailing list
    >> https://stat.ethz.ch/mailman/listinfo/r-devel
    >> 

______________________________________________
    LG> R-devel at r-project.org mailing list
    LG> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list