Skip to content

OT: Reason/history behind ## notation for comments?

3 messages · Henrik Bengtsson, Laurent Gatto, Martin Maechler

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

Best wishes,

Laurent
On 22 September 2010 07:26, Henrik Bengtsson <hb at stat.berkeley.edu> wrote:
1 day later
#
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