[R6RS] R6RS Unicode SRFI controversial issues

Marc Feeley feeley
Sat Jun 18 08:06:42 EDT 2005


On 18-Jun-05, at 3:12 AM, Anton van Straaten wrote:

> I'm in full agreement with all of Kent's points below.
>
> In particular, support for newlines in strings, without a preceding  
> backslash, is very useful for embedding code in other languages  
> (SQL, Javascript, etc.)
>
> I notice that Bigloo, Chez, Gambit, Guile, MIT, PLT, Scheme 48, SCM  
> and SISC all support this now:
>
> "Multi-line strings
> are common
> practice"
> => "Multi-line strings\nare common\npractice"
>
> If a programmer finds either approach easier to read, they're free  
> to choose that approach, i.e. it's a stylistic choice for the  
> programmer. That's preferable to having the standard impose a  
> single solution for all cases, since each is appropriate in  
> different circumstances.
>

I agree that it is convenient for a string to span multiple lines  
when the string is itself composed of newline characters.  However,  
the need to escape some characters makes it painful in some (frequent  
for me) cases.  For example, Gambit has a c-declare special form that  
embeds the string argument in the C code that is generated:

(c-declare "
/* include an important header file */
#include \"macros.h\"
void test () { printf (\"this is a test\\n\"); }
")

Notice all the escapes needed.  It is a real pain to add these in.

> BTW, if Scheme supported something like a "here document", as in  
> sh, bash or perl (http://www.faqs.org/docs/abs/HTML/here- 
> docs.html), then ordinary strings could be more constrained.  I'm  
> guessing we don't want to go that far at this point, though.
>

Gambit has the here-string syntax of Scsh.  The above example would  
be written

(c-declare #<<end-of-c-declare
/* include an important header file */
#include "macros.h"
void test () { printf ("this is a test\n"); }

end-of-c-declare
)

The #<< is followed (to the end of line) by a keyword that must come  
by itself on a line to indicate the end of the string.  All the  
characters between #<<KEY<newline> and <newline>KEY<newline> are  
included verbatim in the string (note that the <newline> before the  
keyword is not included, so that it is possible to have multiline  
strings that don't end in a newline).

Gambit also has the #<X...X syntax of Scsh (where X is an arbitrary  
character which delimits the characters of the string).  It is  
analogous to the \verb|...| form of latex.

How do people feel about these syntaxes?  Based on your response we  
could:

1) drop the here-string syntax and allow newlines in the normal  
string syntax

2) adopt the here-string syntax and allow newlines in the normal  
string syntax

3) adopt the here-string syntax and disallow newlines in the normal  
string syntax

My preference is option 3.

Marc




More information about the R6RS mailing list