From b.rowlingson at lancaster.ac.uk  Thu Aug 20 17:23:26 2015
From: b.rowlingson at lancaster.ac.uk (Barry Rowlingson)
Date: Thu, 20 Aug 2015 16:23:26 +0100
Subject: [Rd] Multi-line comments in R
In-Reply-To: <07b26e74c0cd4f118d00e8a540a59d1b@EX-0-HT0.lancs.local>
References: <07b26e74c0cd4f118d00e8a540a59d1b@EX-0-HT0.lancs.local>
Message-ID: <CANVKczPuy_5+W-6zQ3C67mWQHqufcbD1S-wQfhFT_=O+GBL7wg@mail.gmail.com>

On Wed, Aug 19, 2015 at 5:16 AM, Nathan Esau <nesau at sfu.ca> wrote:
> I was wondering why the decision was made long ago to never implement
> multi-line comments in R. I feel there are several argument to be made for
> why the R language should have multi-line comments.
>
> 1. Many programming languages (including some which are commonly used for
> statistics, such as python, matlab and SAS) have this feature.

 Python doesn't have a multi-line comment.

 You can use triple-quoted strings in Python to quote a large chunk of
text, which won't generate any bytecode and so has no executable
effect:

def foo(x)
 y = x * 2
 """
 well what now
 lets have a comment
 """
 return(y)

A similar thing is possible in R:

 foo = function(x){
    "this is a test.
where
you can comment"
    return(x*2)
}

However I don't know if this causes any executable effect - its
possible R evaluates the string in some way.... Anyone want to test.

Yes, you have to escape any string quote marks in your comment, but in
python you have to escape any triple-quote marks.

Barry



[Rd] Multi-line comments in R
Barry Rowlingson