[R] Is there a construct for conditional comment?
Duncan Murdoch
murdoch at stats.uwo.ca
Thu Aug 20 19:19:19 CEST 2009
On 8/20/2009 11:54 AM, Steve Jaffe wrote:
> Why not
>
> if ( 0 ) {
> commented with zero
> } else {
> commented with one
> }
Because that doesn't work unless the comments are syntactically correct
R. For example, yours gives:
Error in source("clipboard") : clipboard:2:11: unexpected symbol
1: if ( 0 ) {
2: commented with
^
In C++, you can put nearly arbitrary junk in the #if 0 block, and it
will be stripped by the preprocessor.
Duncan Murdoch
>
> Greg Snow-2 wrote:
>>
>> I believe that #if lines for C++ programs is handled by the preprocessor,
>> not the compiler. So if you want the same functionality for R programs,
>> it would make sense to just preprocess the R file.
>>
>>> In C++, I can use the following construct to choice either of the two
>>> blocks the comment but not both. Depending on whether the number after
>>> "#if" is zero or not, the commented block can be chose. I'm wondering
>>> if such thing is possible in R?
>>>
>>> #if 0
>>> commented with 0
>>> #else
>>> commented with 1
>>> #endif
>>>
>>> Regards,
>>> Peng
>>>
>>
>
More information about the R-help
mailing list