On 2014-01-28 17:13, Adrien Vogt-Schilb wrote:
--------------------
On 28/01/2014 16:43, Stefan Du Rietz wrote:
On 2014-01-28 09:54, Adrien Vogt-Schilb wrote:
--------------------
On 28/01/2014 09:41, Stefan Du Rietz wrote:
On 2014-01-27 22:43, Serge Steer wrote:
--------------------
Le 27/01/2014 19:05, Stefan Du Rietz a écrit :

Under pause, you cannot modify a variable which is defined in the
calling context
so in such a context args is not a list as you expect but an empty
array which is implicitely created

To make it work
you must do
-1-> args; //makes a local copy of args
-1->args(1) = null()

Serge

What do you mean by "defined in the calling context"?
I can modify this:

-1->isfast
 isfast  =
    0.    0.
-1->isfast(1) = 1
 isfast  =
    1.    0.

Stefan



Stefan, you may want to have a look at
http://wiki.scilab.org/howto/global%20and%20local%20variables
This page explains what Serge means i believe.

Adrien

Thank you Adrien, but I have had many looks at it ;-)

I still don't understand the difference between my variables args
and isfast. They are both defined in the function.

args: input values of the function are assigned to the corresponding
local variables of the function (local variables and scoping 5.)

isfast: local variables defined at level_N remain local at that
level. (local variables and scoping 2.).

What am I missing? Am I just stupid?

Stefan

I believe the local and global variable stuff explains why you are
able to reproduce your bug only under pause, as documented here
http://wiki.scilab.org/howto/global%20and%20local%20variables (gosh,
the page does not explain that pause and functions behave the same
way... this is probably our problem here)
This means that there is not "strange list error", only a confusing
behaviour of scilab under pause. If i am correct, none of your
functions suddenly stopped working.

The function suddenly stopped working because of an error by me, which I reported 2014-01-25 21:07. It was when I debugged my function that this *pause* problem showed up.

Coming back to the original post:

-1->args(1) = null();
args(1) = null();
                  !--error 44
Wrong argument #2.

and when I checked:
-1->typeof(args)
  ans  =
  list

Can anybody explain that?

The explanation is that you just created a new pause environment,
where args do no exist yet.

But why only args (from varargin)? isfast does exist. And if I add a variable *a* before varargin, I can change that after *pause*.

Changed in testlisterror.sci:
function isfast = testlisterror(a, varargin)

  The line -1->args(1) = null(); (witten just after entering in pause)
then behaves exactly the same way as if you open a new scilab consoloe
and write args(1) = null()

In other words, you cannot debug your function using pause like that.

I have long ago understood pause as a means to be able to be in the environment of the function and manipulate things from the command line, and I have mostly been successful in doing that. Here, you cannot do that and there is nowhere a comment on it.

In the precise case of your function, one thing that would work is to
pause the function just after entering (before the line args =
varargin;), or to use the solution Serge gave you, that is replace the
lines 8 and 9
pause
     args(1) = null();
with
pause
args; //makes a local copy of args in the new pause environment
     args(1) = null();


And how do I know which variables need that? See above about *a*.

Please make sure you understand that nothing discussed here as nothing
to do with your function, (which i did not read and i bet serge did
not read).
The bug comes from how you use pause to try to debug your function
(and yes, this is very annoying as it prevents to use pause to debug
scilab seamlessly.).

I'm confused whether this answer your original question, and whether
you have more questions

Adrien

If it is so annoying, should we not report a bug?

Stefan


_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users

Reply via email to