help-octave
[Top][All Lists]
Advanced

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

Re: input with line break


From: Santiago Higuera
Subject: Re: input with line break
Date: Sun, 6 Oct 2019 10:06:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

Thanks, Przemek.  I didn't know.

I read in 'Free your numbers'

5.1 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.

I read in 'help fprintf':

Implementation Note: For compatibility with MATLAB, escape
     sequences in the template string (e.g., "\n" => newline) are
     expanded even when the template string is defined with single
     quotes.

It's a little confused for me, I don't understand why  single and double quoted string are different. I don't understand what is the objective or the advantage of this difference.

Regards
Santiago Higuera

El 4/10/19 a las 22:00, Przemek Klosowski via Help list for GNU Octave escribió:
On 10/3/19 5:12 PM, Santiago Higuera wrote:
Hi all:

I'm using Ocatve 5.1, and I've observed that if I use:

x=input("x= \n")

The special character '\n' is recognized, but if I use single quoted string, it is not recognized.

Is it a bug? In MATLAB single quoted string recognize the special character for line break in input() function.

I don't consider it a bug---it's a convention used in many other places (e.g. the shell)

Matlab disregards escape characters in both forms, but seems to special-case escape characters (at least \n) in input(). Octave doesn't need to because you can pass them in double-quoted strings.

It is a minor Octave-Matlab incompatibility but I just think Octave does it better. Are there other known cases of special-casing escapes in Matlab?






reply via email to

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