octave-maintainers
[Top][All Lists]
Advanced

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

Re: more import tests


From: John W. Eaton
Subject: Re: more import tests
Date: Thu, 10 Aug 2017 16:29:38 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

Thanks for running the tests.

Some things I noticed:

** The test of a user-defined import function shows that it is only executed if it is called with the function-style syntax, but not if called with command-style syntax. For command-style syntax, it appears that the user-defined import function is ignored. Does that happen for ANY other function name in Matlab?

** If the command-style syntax is used, then it appears to affect all function calls, as Rik noted. So when a command-style import statement is parsed, the import name is added to a list that will affect function lookup. This can be done when the function that contains the import statement is parsed or when it is evaluated. Doing it at parse time requires a lot more smarts for the parser because it must determine what is a variable vs. what is a function. Octave is not quite there yet. Also, I need to test what happens when eval is used to give a symbol a value when that symbol also exists as a function. For example:

  import pkg.sin;
  eval ('sin = pi');
  sin (1)

Is pkg.sin called, or does sin (1) index the variable sin? Does the result change if sin is "declared" to be a variable?

  sin = [];
  import pkg.sin;
  eval ('sin = pi')
  sin (1)

I suspect that in the former case, the variable sin is ignored, but in the latter case, sin is treated as a variable, not the pkg.sin function.

** If the function-style syntax is used, then import still has an effect, but it behaves more like a normal function, and only changes the lookup for symbols that appear after the call to import.

** If an import function isn't found, it's an error.

jwe




reply via email to

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