octave-maintainers
[Top][All Lists]
Advanced

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

Re: Continuation lines


From: John W. Eaton
Subject: Re: Continuation lines
Date: Wed, 03 Apr 2013 10:32:49 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20121122 Icedove/10.0.11

On 04/03/2013 10:18 AM, Jordi Gutiérrez Hermoso wrote:
On 3 April 2013 01:29, John W. Eaton<address@hidden>  wrote:

   * deprecating and ultimately eliminating \ as a continuation
    marker

I was with you up to here. What is the problem with having two kinds
of continuation markers? Is it the difficulty of maintaining both of
them? I know that \ is also the left division operator, but I don't
think this has ever caused an actual problem. It's nice that other
programming languages that need continuation characters also use a
backslash, not just C. I am thinking of Ruby and Python. Ruby and R
also wait until they get a "complete" statement before evaluating, so
something like this would work there.

    x = 2 + ## something needs to come after this +
        3;

AIUI, the new push parser would be able to handle this now?

Yes, the push lexer/parser can accept a line at a time and still
handle continuations.  It just returns and tells you "give me more
input".  The only place where this currently doesn't work is in
character string continuations.  It's not that it can't work, it's
just that I haven't fixed it yet.

On the other hand, Octave has another line continuation method that
Matlab doesn't: round brackets (parens) will continue to the next line
if they're not closed. I use this method in Python for line
continuations, so if we do get rid of the backslash continuations, I
propose we substitute it with bracket continuation, e.g. replace

    x = 2 \
        + 3;

with

    x = (2
         + 3);

The only situation in which this doesn't work is when writing matrix
"literals" with []. In those cases, I suppose we would have to use ...
instead.

Hmm, inside [] or {}, parens should work as usual.  So

  [(1
   + 2)]

should produce 3.  That should work in both the old and the new
parser/lexer.  Or maybe you are thinking of some other case?

Note also that we are not actually using the push interface for the
anything yet.

If we keep the \ continuations, what about deprecating comments and
whitespace between the \ and \n and eventually requiring that the
backslash is followed immediately by a newline character and nothing
else?

But either way, I think we should make ... work as in Matlab, which
means allowing arbitrary text to follow it but not allowing it as a
continuation marker inside character strings.  I guess we can start
there.

jwe


reply via email to

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