help-octave
[Top][All Lists]
Advanced

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

Re: space vs semicolon - why syntax error with the former ? (octave-3.4.


From: CdeMills
Subject: Re: space vs semicolon - why syntax error with the former ? (octave-3.4.2)
Date: Wed, 17 Aug 2011 01:04:43 -0700 (PDT)

Sergei Steshenko-2 wrote:
> 
> Hello,
> 
> here is a screen session:
> "
> octave:1> for ii=1:1 ii endfor disp(ii)
> parse error:
> 
>   syntax error
> 
>>>> for ii=1:1 ii endfor disp(ii)
>                             ^
> 
> octave:1> for ii=1:1 ii endfor;disp(ii)
> ii =  1
>  1
> octave:2>
> ".
> 
> Why is it so 'octave' doesn't accept the first variant ?
> 
> With "traditional" 'endfor' on a new line semicolon isn't needed ?
> Is there any reason for newline whitespace to be treated differently than
> space whitespace ?
> 
> 

1) there is no such thing as a newline whitespace. It's a newline
terminator.
2) some keywords stop the parsing of the _previous_ expression: else, end,
...
3) the logic is that, if you require to pack on one line:
a = 3
b = 2
you have the choice between
a = 3; b = 2
or 
a = 3, b = 2
This way, to pack
if (1> 0) c=3 else d=4 end
a = 3
You need either 
if (1> 0) c=3 else d=4 end, a = 3
or
if (1> 0) c=3 else d=4 end; a = 3
My interpretation is that ';,' used as secondary separator must come where
the primary separator (newline) is expected.

Quite franckly, I expect to make some keywords (end, endfor, ...)  become
separators of their own to be disruptive, leading to subtle and hard to
track problems.  

Regards

Pascal



--
View this message in context: 
http://octave.1599824.n4.nabble.com/space-vs-semicolon-why-syntax-error-with-the-former-octave-3-4-2-tp3746937p3749356.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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