octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Matlab-compatible string class


From: Daniel J Sebald
Subject: Re: Matlab-compatible string class
Date: Sun, 31 Dec 2017 16:19:53 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 12/30/2017 08:27 PM, Daniel J Sebald wrote:

Here's a couple other ideas, but first it seems that no matter what one does here there is a backward compatibility issue. Making the change will mean that there is probably lots of user-written Octave scripts out there using escape-strings that no longer works perfectly. (One solution is a translator, which I'll come back to.)

1) This idea isn't too much different than the compatibility option. Have the routine eval() accept an input option "legacy", "escapestring", "cstylestring" that will treat all strings as escape-strings, i.e., C-style. That way, if someone has some code with escape characters in it, s/he can still use it. (BTW, I assume the only way to get escapes into new-strings will be via sprintf.)

2) Introduce a new escaped-string or C-style-string syntax using a character that isn't likely to be used for something else in a syntactical sense. For example, currently the following (and many other variations) creates a syntax error:

octave:1> x = \"This is an\nescaped string.\n"
parse error:

   syntax error

 >>> x = \"This is an\nescaped string.\n"
         ^

It just came to mind, this isn't quite an invalid syntax because of the operator \ used in scalar cases, i.e.,

octave:11> 1 \"/"
ans =  47

Ergo, neither is this proposal

octave:2> x = /"This is an\n\"escape\" string.\n/"
x = This is an
"escape" string.

acceptable because

octave:12> 1 /"/"
ans =  0.021277

So that's out.  However, the following

octave:23> 1 \\"/"
parse error:

  syntax error

>>> 1 \\"/"

fails, so one could make \\"" mean an escape string, e.g.,

octave:10> x = \\"This is an\n\"escape\" string."
x = This is an
"escape" string.

Otherwise, there are the $ and ? character that don't seem to be used. Again, $This is a \"C-style\" string.$ seems sort of odd.

Dan

PS: I wouldn't say the string class is too urgent an issue. I'd guess that new features in commercial apps take years to reach critical mass, unless it is something users have been clamoring for. That could be the case, maybe if string class is related to use in big-data or database studies.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]