Bill Allombert on Mon, 01 Apr 2013 23:29:26 +0200


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

Re: Idiom: allocatemem in a script


On Mon, Apr 01, 2013 at 12:18:38PM +0200, Dirk Laurie wrote:
> If you have a script with `allocatemem` in it, the script
> runs to completion if invoked by `gp myscript.gp`.
> If invoked by `read("myscript.gp")` inside an interactive
> session, it runs up to the first `allocatemem` and returns.

Note that you can do
\r myscript.gp
if you want the behaviour of gp myscript.gp.

> I've always thought of this behaviour as an undesirable
> side effect of the implementation,

This is a side effect of allocatemem destroying the PARI stack. 

> but I have now come
> to realize that it is a feature, not a bug.
> 
> It's a neat, clean way to separate the test code
> in a module from the library code. So, even when
> I don't need to change the stack size, I'm putting
> `allocatemem` in from now on.

Very interesting, I never thought of that.

Cheers,
Bill.