Re: [Rd] Multi-line string constants: proposed patch

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Sat 11 Sep 2004 - 09:29:33 EST

Kevin Wright <kwright@eskimo.com> writes:

> R 1.9.1 requires multi-line strings to contain a backslash at the
> end of each line (except the last line). As noted by Mark
> Bravington (http://tolstoy.newcastle.edu.au/R/help/02b/5199.html)
> this requirement appears to be undocumented.
>
> In S-Plus 6.2, multi-line strings do not need a backslash for continuation.
>
> I recently (http://tolstoy.newcastle.edu.au/R/devel/04b/0256.html)
> requested compatability with S-Plus and was told to contribute
> a patch and then it would be considered. Here is the proposed patch.
>
> In the files src/main/gram.y and src/main/gram.c strings
> are parsed with the StringValue function. Looking at the function it is
> clear that a newline character (not the two-byte '\n') generates an error:
>
> static int StringValue(int c)
> {
> ...
> if (c == '\n') {
> xxungetc(c);
> return ERROR;
> }
>
> ...
> }

...
>
> C:\R\R-devel\src\main>diff ogram.c gram.c
> 3122,3125c3122,3125
> < if (c == '\n') {
> < xxungetc(c);
> < return ERROR;
> < }
> ---
> // if (c == '\n') {
> // xxungetc(c);
> // return ERROR;
> // }
>
> Presumably the same change should be made in gram.y
>
>
> Thanks for considering this patch.

Sorry, I don't think that is good enough (notwithstanding the nonstandard comment character). Notice that Splus does this:

> x <- "foo

Continue string: bar
Continue string: baz"

(and the entry is interruptible with Ctrl-C too)

There's a very good reason for the change of prompt, as anyone who has debugged SAS code with stray quotes will tell you: The system would appear to be completely unresponsive because all input is being eaten by the string readers.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

______________________________________________
R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sat Sep 11 09:42:04 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:45:14 EST