On 4/25/07, skaller <[EMAIL PROTECTED]> wrote:
> It opens up the issue of what
> to do with string literals. In Python it is very painful,
> because the literals don't support nice block indent style.

I've always liked the algorithm used by the textwrap module that Erick
mentions: starting with the second line (i.e. the first one after the
triple-quote), dedent all lines uniformly until the last one.  The
only thing it's missing IMHO is that it should also remove the first
line if it's blank (thus eliminating bugs such as the one in the
webserver).  Works nicely for docstrings, etc.  The problem that
arises of course is what to do with mixed tabs / spaces; I'd say just
dedent until mismatched indentation is encountered.

Another idea I like is how O'Caml's escaped-end-of-line means "elide
the newline and all leading whitespace on the next line".  Very
convenient for wrapping long lines.  I'd suggest this behavior for
both docstrings and normal strings in Felix.

> In this case .. attempts to make the code look nice
> turn out to cause a bug. AFAICR trailing whitespace
> is elided (because you can't see it). Thus
>
> """hello
> """
>
> will be 'hello\n' even if you put extra ' ' after hello.
> If you put
>
> """hello   \
> """
>
> it adds the white space .. but removes the \n ... ;(

Keep this behavior!  It's very consistent in a do-what-I-mean fashion,
and it's consistent with the O'Caml-style end-of-line escapes too
(where the trailing whitespace is needed).  If someone really wants
trailing whitespace for some other reason, they should really just be
using normal strings (which, with end-of-line escapes, are well-suited
to entering precise string data).  I think treating triple-quotes as a
do-what-I-mean construction, and single-quotes as do-what-I-say, will
generate the least amount of "surprise" for people coming from other
languages.

- Chris

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to