[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Single vs. Double Quotes
From: |
Søren Hauberg |
Subject: |
Re: Single vs. Double Quotes |
Date: |
Sat, 15 Oct 2011 20:00:58 +0200 |
lør, 15 10 2011 kl. 10:36 -0700, skrev Rik:
> > While testing mirone with QtHandles, I found an issue with strread and
> > \n delimiter,
> > when the delimiter is double-quoted or single-quoted. It boils down to
> > the following:
> >
> > octave-qt.exe:5> strread(sprintf('1\n2\n3'), '%d', 'delimiter', '\n')
> > ans = 123
> > octave-qt.exe:6> strread(sprintf('1\n2\n3'), '%d', 'delimiter', "\n")
> > ans =
> >
> > 1
> > 2
> > 3
> >
> > As ML doesn't have double-quoted strings, only the first form is valid, but
> > from
> > what I can see from mirone code, it looks like in ML, the first form
> > actually gives
> > the second result. Can anybody confirm? Do we want to change this in octave?
> Ugh. No. Every other reasonable lexical interpreter (Bourne shell, C
> shell, Perl, Python, etc.) makes a distinction between single and double
> quotes. A double quoted string is interpreted such that special escape
> sequences like "\n" are translated into the actual character(s) the
> sequence represents. In this case, "\n" becomes newline which may be a
> carriage return, CR, line feed, LF, or CRLF depending on platform. On the
> other hand, sometimes you don't want such interpretation if you are
> actually looking for the '\' character. The single quotes turn off
> interpretation and makes this possible.
I think most people agree that "\n" should be interpreted as a newline
and that '\n' should be a '\' and a '\n' in general.
The question here is if the 'delimiter' option to 'strread' should
deviate from this rule just as the '*printf' functions do.
Søren
- Re: Single vs. Double Quotes, (continued)
- Re: Single vs. Double Quotes, John W. Eaton, 2011/10/15
- Re: Single vs. Double Quotes, Michael Goffioul, 2011/10/15
- Re: Single vs. Double Quotes, John W. Eaton, 2011/10/15
- Re: Single vs. Double Quotes, Ben Abbott, 2011/10/16
- Re: Single vs. Double Quotes, Rik, 2011/10/16
- Re: Single vs. Double Quotes, Ben Abbott, 2011/10/16
- Re: Single vs. Double Quotes, John W. Eaton, 2011/10/17
- Re: Single vs. Double Quotes, Ben Abbott, 2011/10/17
- Re: Single vs. Double Quotes, John W. Eaton, 2011/10/17
Re: Single vs. Double Quotes, Rik, 2011/10/15
Re: Single vs. Double Quotes,
Søren Hauberg <=
Re: Single vs. Double Quotes, John W. Eaton, 2011/10/15