octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #43769] error: invalid meta.package indexing w


From: Rik
Subject: [Octave-bug-tracker] [bug #43769] error: invalid meta.package indexing when using strfind function
Date: Fri, 30 Jan 2015 23:42:51 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:35.0) Gecko/20100101 Firefox/35.0

Follow-up Comment #5, bug #43769 (project octave):

The patch fixes the original reported problem with 'edit strfind.cc'.  There
is still an issue, which I could open as another bug, that I can call a C++
function with it's file name and not get an undefined error.  Maybe this has
more to deal with the parser than the classdef code?


givens.cc (1,1)
error: Invalid call to givens.  Correct usage is:

 -- Built-in Function: G = givens (X, Y)
 -- Built-in Function: [C, S] = givens (X, Y)

givens.xyz (1,1)
error: Invalid call to givens.  Correct usage is:

 -- Built-in Function: G = givens (X, Y)
 -- Built-in Function: [C, S] = givens (X, Y)



It appears that the parser hits the struct indexing operator '.' and then
checks to see if the token behind it is valid.  Presumably, this should be a
struct or class instance variable.  But it appears to check only that it is a
valid identifier which could be a variable, but could also be a function. 
Octave then processes the token which is the function call givens() with no
arguments.  That produces an error.  Maybe the parser needs to be more careful
about what sort of argument is on the left-hand side of the struct indexing
operator.

It already knows not to allow some things, like matrices and cells.


(givens (1,1)).cc
error: matrix cannot be indexed with .
{1,2}.cc
error: cell cannot be indexed with .



Maybe this is too hard to solve though.  There could be functions which take
no arguments, but return a struct, which could then be indexed.


function r = x ()
  r = struct ("cc", "Hello World");
endfunction
x.cc
ans = Hello World


So, maybe I've talked myself into believing this has to stay the way it is. 
One possible improvement in clarity would be to disallow bare word functions
on the left side of the indexing operator.  So


x.cc  # valid when x is a class or a struct.
x ().cc  # Required parentheses when one is really trying to index the return
value of a function 'x'.




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?43769>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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