octave-maintainers
[Top][All Lists]
Advanced

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

Re: line continuations


From: Nicholas Jankowski
Subject: Re: line continuations
Date: Thu, 20 Feb 2020 13:14:09 -0500


is extension is semantic. The function is called
strrep. The help of that function says:

"""
 -- NEWSTR = strrep (STR, PTN, REP)
 -- NEWSTR = strrep (CELLSTR, PTN, REP)
 -- NEWSTR = strrep (..., "overlaps", VAL)

Replace all occurrences of the pattern PTN in the string STR with the string
REP and return the result.
"""

My objection is that an example like the one we have been using
c = ['1 2 3';'4 5 6']

where IMHO c is not a string. I called it an array of chars to distinguish
from a vector of chars.

so, one point here, these aren't strings.  (strings didn't exist, i don't even think cell arrays existed, when this function was made).  i don't know if this matlab's behavior changed over time with cell arrays and strings. But, allowing char arrays does produce odd results:

in addition to the case above:

octave:5> c = ['1 2 3 4 5 6']
c = 1 2 3 4 5 6

octave:6> strrep(c,'1 2', '6 7')
ans = 6 7 3 4 5 6

octave:7> c = ['1 2 3';'4 5 6']
c =

1 2 3
4 5 6

octave:8> strrep(c,'1 2', '6 7')
ans =

1 2 3
4 5 6

octave:9> strrep(c,'14', '67')
ans = 67  25  36

so it is odd.  I don't see any real definition or explanation in the docs to clarify this. So maybe it's not intentional. 

filed a bug report (https://savannah.gnu.org/bugs/?57867)  as either it should be changed or documented. 


reply via email to

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