Question: Why does the restart command behave so?

Should restart always be in separate execution group? I noticed when I write something like

>restart;
  foo:=proc()
  local sys;
  with(DynamicSystems):
  sys := TransferFunction(25/(s^2+4*s+25)):
  print(ResponsePlot(sys, Step(),duration=4));
end proc;
>

then type foo(); in the next execution group, it does not work. The plot is not generated. No matter how many times I evaluate the execution group. The proc() does not seem to be fully defined. But if I do this:

>restart;  #hit return
>foo:=proc()
  local sys;
  with(DynamicSystems):
  sys := TransferFunction(25/(s^2+4*s+25)):
  print(ResponsePlot(sys, Step(),duration=4));
end proc;
>#hit another return

and now calling foo(); then it works, and the proc() returns the plot. Only difference is that restart was in separate group. But also I had to call foo() once, then evaluate the execution group where foo() is defined two times ! for it to work (why two times?) why one time did not work? is it becuase I am loading package inside the proc()?

What are the rules for putting the restart() call? Should it always be in separate group? I put it in the same group, so that I do not have to hit return 2 times, being a lazy person. But it seems to cause problem sometimes.

And related question, why did I have to hit return 2 times in the execution group to have proc() work in the second case above?

 

Please Wait...