octave-maintainers
[Top][All Lists]
Advanced

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

Re: Matlab-compatible string class


From: Rik
Subject: Re: Matlab-compatible string class
Date: Thu, 28 Dec 2017 08:41:00 -0800

On 12/27/2017 09:38 PM, address@hidden wrote:
Subject:
Matlab-compatible string class
From:
"John W. Eaton" <address@hidden>
Date:
12/27/2017 02:47 PM
To:
Octave Maintainers List <address@hidden>
List-Post:
<mailto:address@hidden>
Content-Transfer-Encoding:
7bit
Precedence:
list
MIME-Version:
1.0
Message-ID:
<address@hidden>
Content-Type:
text/plain; charset=utf-8; format=flowed
Message:
3

With this change:

  http://hg.savannah.gnu.org/hgweb/octave/rev/0b65949870e3

we are beginning to handle the existence of the Matlab string class that is now created in Matlab when double quoted strings are used.  I expect that it will not be too long before users will expect full compatibility in this area.  But I'm not sure how we will transition from Octave's current behavior for double-quoted string constants to the one now used by Matlab.  For example, in  Octave "foo\n" is a 4-element character array containing 'f', 'o', 'o', and a linefeed character.  In Matlab it is a string object, but it also contains 5 characters, 'f', 'o', 'o', '\', and 'n'.  I'm sure there are other differences, but this is sure to cause some trouble.  I don't see a smooth transition path.  Does anyone have any ideas about what to do?

jwe

I don't see a smooth transition path either.  Although Matlab presents the string class as a fundamental data type, it is actually closer to a container data type like a cell array.  In fact, by using cell arrays of strings you can make portable code that will run in either Octave or Matlab.  Maybe this is unkind, but the principal advantage seems to be the syntactic sugar of using parentheses '()' for indexing rather than cell array indexing '{}'.

Since string arrays are really a data container type, they just contain ordinary Matlab strings which we already know to be the equivalent of single-quoted 1xN character row vectors.  Hence, '\n' is two characters even within a string array created with quotes.

This is probably such an involved topic, with architectural implications, that we should discuss it face-to-face at OctConf 2018.

--Rik


reply via email to

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