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: Sergei Steshenko
Subject: Re: space vs semicolon - why syntax error with the former ? (octave-3.4.2)
Date: Tue, 16 Aug 2011 05:03:10 -0700 (PDT)


--- On Tue, 8/16/11, Ben Abbott <address@hidden> wrote:

> From: Ben Abbott <address@hidden>
> Subject: Re: space vs semicolon - why syntax error with the former ? 
> (octave-3.4.2)
> To: "Sergei Steshenko" <address@hidden>
> Cc: address@hidden
> Date: Tuesday, August 16, 2011, 4:55 AM
> On Aug 16, 2011, at 7:25 AM, Sergei
> Steshenko 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 ?
> > 
> > Thanks,
> >  Sergei.
> 
> The parser treats keywords and functions differently.
> 
> I am not familiar with the parser implementation, so I
> can't give a better explanation. To see what Octave's
> keywords are, you can use the undocumented function
> __keywords__.
> 
> To see what functions are in the path, use
> __list_functions__.  There are builtin function as
> well. To see those use __builtins__.
> 
> Ben
> 
> 

I do not grasp your reply. My point is that in "normal" languages all
whitespaces are created equal. So, since the following works:

"
octave:1> for ii = 1:1
>   ii
> endfor
ii =  1
octave:2> disp(ii);
 1
octave:3>           
"

, and in this case 'endfor' is separated from 'disp' by newline, I  also
expect

"
octave:3> for ii = 1:1 ii endfor disp(ii);
parse error:

  syntax error

>>> for ii = 1:1 ii endfor disp(ii);
                              ^

octave:3>    
",

to work (because newline and space both look like created equal whitespaces to 
me), but it doesn't.

Thanks,
  Sergei.


reply via email to

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