[Top][All Lists]

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

Re: HELP a newbie - Weird problem

From: John Eaton
Subject: Re: HELP a newbie - Weird problem
Date: Wed, 23 Aug 1995 23:43:15 -0500

Ted Harding <address@hidden> wrote about problems with

: If you start up octave, and immediately execute "conv(1,1)", then PROVIDED
: the variable whitespace_in_literal_matrix is a null string the result will
: be correct. You can then set whitespace_in_literal_matrix='traditional'
: and re-execute "conv(1,1)" and it will still work. This is because the
: m-file for "conv" has already been read in, parsed, understood, and
: "compiled" into octave's internal format.

Right.  Some of the preference variables only matter when Octave is
`compiling' input into its internal form.

: However, if you first execute whitespace_in_literal_matrix='traditional'
: and THEN do "conv(1,1)" you will get
:       parse error near line 59 of file conv.m:
:       >>>       x = [b, zeros (1, ly - lb)];
:                                  ^
: no doubt because it tries to evaluate "[b, zeros (1, ly - lb)]" as a
: matrix with columns  "b"  and  "zeros" and "(1, ly - lb)" (or somthing to
: that effect) because the "traditional" column separator in a Matlab
: literal matrix is the space.  (Can experts confirm that this reading is
: [approx] correct?).

Yes.  Octave is inserting a comma between `zeros' and the following
`('.  Then the remaining input doesn't make sense.

Rather than go to all the trouble to `fix' the parser to attempt to
read the programmer's mind, it will be much easier (though probably
not trivial) to fix the functions so that they will work with any
combination of the preference variables.  (I hope I have not done
something stupid that makes this impossible! :-)

To make things work correctly no matter what the value of
whitespace_in_literal_matrix, I believe it is sufficient to (1) always
use `,' and `;' to separate elements and rows and (2) omit spaces
between variable names and '(' when it is used for indexing.  I plan
to do at least this for the next release.  Instead of (2), you can
use a temporary variable to move the expression outside the literal

  tmp = zeros (1, ly - lb);
  x = [b, tmp];

or you can put the expression inside parentheses,

  x = [b, (zeros (1, ly - lb))];

This works because Octave turns off the auto-insertion of commas
inside the parentheses.

Another possibility that has been mentioned is to allow some way of
setting the compile-time preference variables on a per-function basis.
I haven't given this enough thought yet to see exactly how to make it
work (either efficiently or at all or without being too confusing)...

As Ian Searle noted, `Can you say "bad language design" :-)'.


reply via email to

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