[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#46327: 28.0.50; octave-mode: transpose-quotes taken as string-quotes
From: |
Basil L. Contovounesios |
Subject: |
bug#46327: 28.0.50; octave-mode: transpose-quotes taken as string-quotes |
Date: |
Sun, 07 Feb 2021 14:48:47 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Juang Dse <juangdse@gmail.com> writes:
>
>> Note that the ' character as a string occurs only in pairs, which is
>> (hopefully) unambiguous.
>
> Can an Octave string span several lines? In that case, it's ambiguous
> whether
>
> x = [2 2]'
> disp(x)
>
> is a transpose character, or an error (with a forgotten ' somewhere), I
> guess.
I'm new to Octave, so I could be wrong, but AFAIK single-quoted string
literals do not support line continuations. The only special construct
they may contain is '' which inserts a single '.
Quoth (info "(octave) Strings"):
Since the single-quote mark is also used for the transpose operator
(*note Arithmetic Ops) but double-quote marks have no other purpose in
Octave, it is best to use double-quote marks to denote strings.
Quoth (info "(octave) Escape Sequences in String Constants"):
In double-quoted strings, the backslash character is used to introduce
“escape sequences” that represent other characters. For example, ‘\n’
embeds a newline character in a double-quoted string and ‘\"’ embeds a
double quote character. In single-quoted strings, backslash is not a
special character. Here is an example showing the difference:
[...]
In a single-quoted string there is only one escape sequence: you may
insert a single quote character using two single quote characters in
succession. For example,
'I can''t escape'
⇒ I can't escape
Quoth (info "(octave) Continuation Lines"):
In the Octave language, most statements end with a newline character and
you must tell Octave to ignore the newline character in order to
continue a statement from one line to the next. Lines that end with the
characters ‘...’ are joined with the following line before they are
divided into tokens by Octave’s parser. For example, the lines
x = long_variable_name ...
+ longer_variable_name ...
- 42
form a single statement.
Any text between the continuation marker and the newline character is
ignored. For example, the statement
x = long_variable_name ... # comment one
+ longer_variable_name ...comment two
- 42 # last comment
is equivalent to the one shown above.
Inside double-quoted string constants, the character ‘\’ has to be
used as continuation marker. The ‘\’ must appear at the end of the line
just before the newline character:
s = "This text starts in the first line \
and is continued in the second line."
Apparently ellipsis continuation lines were also once supported in
double-quoted string literals:
octave:1> "foo ...RET
warning: '...' continuations in double-quoted character strings are
obsolete and will not be allowed in a future version of Octave;
please use '\' instead
HTH,
--
Basil