octave-maintainers
[Top][All Lists]
Advanced

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

Re: Parsing order for matrices


From: Ben Abbott
Subject: Re: Parsing order for matrices
Date: Thu, 18 Oct 2012 05:47:22 -0400

On Oct 18, 2012, at 3:50 AM, Daniel J Sebald <address@hidden> wrote:

> In trying to observe the whitespace-between-function-name-and-parenthesis I 
> noticed the following behavior:
> 
> octave:27> zeros (1, 10)
> ans =
> 
>   0   0   0   0   0   0   0   0   0   0
> 
> octave:28> [zeros (1, 10)]
> parse error:
> 
>  syntax error
> 
>>>> [zeros (1, 10)]
>               ^
> 
> octave:28> [zeros(1, 10)]
> ans =
> 
>   0   0   0   0   0   0   0   0   0   0
> 
> Is it correct that the second case should be invalid and syntax error? I'm 
> guessing that the parsing of the whole matrix comes before parsing of the 
> elements, i.e., on the first pass Octave thinks the second case is ["zeros" 
> "(1, 10)"].  Notice that Octave never gets to the stage of evaluating "zeros" 
> otherwise that too would have been a syntax error.
> 
> It seems to me that the algorithm could be altered slightly to evaluate an 
> individual element before proceeding to the next element.  I can't think of 
> any ambiguity off hand.
> 
> Dan

To preserve the space, I'm I'm the habit of adding an extra set of parentheses

[(zeros (1, 10))]

Ben


reply via email to

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