Problem concatenating structures.

John W. Eaton jwe at bevo.che.wisc.edu
Thu Jul 31 11:46:45 CDT 2008


On 31-Jul-2008, David Bateman wrote:

| John W. Eaton wrote:
| >   octave:5> whos
| >   Variables in the current scope:
| >
| >     Attr Name         Size                     Bytes  Class
| >     ==== ====         ====                     =====  ===== 
| > 	 ans          1x15                       373  struct
| > 	 warning      0x0                          0  double
| >
| >   Total is 15 elements using 373 bytes
| >
| > I'm not sure yet what is causing warning to be assigned, but I'll see
| > if I can find out and fix it.
| >   
| Hey why didn't I think of checking whos, I was looking at the 
| Octave_map::concat and Fwarning functions as the source.. So the cause 
| of the error is obvious, just not the cause of the assignment of 
| warning.. Strange..

The problem is the call to force_local_variable in the
handle_identifier function in lex.l.  The code that calls
force_local_variable is trying to solve the problem of parsing a
command-style function that is used as a variable name, but it is
doing it in a heavy-handed way.  For example, if we are parsing
something like

  [warning, cd, who] = svd (rand (10));

then warning, cd, and who should be marked as variables.  But at the
moment, this case is not distinguished from something like

  [warning, cd, who]

and in both cases, the identifiers are entered into the local symbol
table as variables.  I think the solution is keep a list of the
potential local variable names but only insert them in the symbol
table once the assignment operator is parsed.

Or, we could just go for compatible behavior here and only recognize
command-style functions at the beginning of a statement, and only if
the following token and whitespace makes it look like a command rather
than some other kind of expression.  We've discussed this before, and
I think more or less agreed that this would be reasonable to do in the
long term, but it requires more extensive parser and lexer changes so
I'm not sure I want to do it just now.

jwe


More information about the Bug-octave mailing list