From help-octave-request at bevo dot che dot wisc dot edu Wed Jan 28 15:13:31 1998 Subject: parsing problem. Bug? From: "John W. Eaton" To: Andy Adler Cc: help-octave at bevo dot che dot wisc dot edu Date: Wed, 28 Jan 1998 15:13:11 -0600 On 28-Jan-1998, Andy Adler wrote: | I've had the following parsing problem. I get the same | error in octave 2.0.9 and 2.1.2. | | if you try to define a vector | | octave:69> a=b=c=d=1; | octave:70> [a b (c+d)] | error: invalid vector index = 2 | error: evaluating index expression near line 70, column 5 This is parsed as a b (c+d) variable index-expression | If you bracket the b the answer is wrong | octave:70> [a (b) (c+d)] | ans = 1 2 This is parsed as a (b) (c+d) index-expression binary-expression | You need to give everything brackets | octave:71> [(a) (b) (c+d)] | ans = | 1 1 2 You could just write `[a b c+d]', or use a temporary variable: d = c+b; [a b d] or, as you say, use commas where they are needed. | I realize that the right_thing_to_do (tm) is use commas to | separate elements, but I think this behaviour is a bug. | | PS. In matlab you get | >> [a b (c+d)] | ans = 1 1 2 If there is a bug, I think it is in the way that Matlab treats whitespace differently in different contexts. If you want the Matlab behavior, you can set the variable `whitespace_in_literal_matrix' to "traditional". jwe