Reading a script gives error, but directly using the script's content works

Questions and problems about using polymake go here.
User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: Reading a script gives error, but directly using the script's content works

Postby gawrilow » 24 Mar 2017, 13:04

Well, maybe the function name sounds misleading. simulate_shell_input does exactly what you want, just avoiding any fuss with pseudo-terminals, because perl can process any strings as long as they fit into the memory. Thus if you start polymake using the callable library object polymake::Main, it does not look for any ttys but waits for commands supplied via simulate_shell_input (and other functions provided by the callable library, of course). The advantage over scripts is, first, less overhead - no need to create temp files and wipe them away later, second, no stored precompiled script bodies, and third, homogeneous syntax rules: the input provided by this function is treated more rigorously, without automatic declaration. If you want polymake to keep track of the variables, then all you need is to issue a 'declare $SAGE27;' when the variable comes into existence on the Sage side, then you can assign anything you want to it as long as the session lasts, or undef it if you want to save memory but keep the variable declared. You can even introduce one large array of variables, like @SAGEVAR, which you declare during the start-up and then substitute $SAGEVARS[27] in all expressions.

SimonKing
Posts: 14
Joined: 01 Mar 2017, 12:36

Re: Reading a script gives error, but directly using the script's content works

Postby SimonKing » 24 Mar 2017, 14:49

Well, maybe the function name sounds misleading. simulate_shell_input does exactly what you want, just avoiding any fuss with pseudo-terminals, because perl can process any strings as long as they fit into the memory. Thus if you start polymake using the callable library object polymake::Main, it does not look for any ttys but waits for commands supplied via simulate_shell_input (and other functions provided by the callable library, of course).
As I said before: This is useful for a library interface (pypolymake), but doesn't apply to a pexpect interface.

User avatar
gawrilow
Main Author
Posts: 423
Joined: 25 Dec 2010, 17:40

Re: Reading a script gives error, but directly using the script's content works

Postby gawrilow » 24 Mar 2017, 17:04

Understood. At least, you should generate all your temporary scripts with the same file name, then polymake will store only one compiled script body.


Return to “Helpdesk”