Page 1 of 1

Using modules with polymake

Posted: 15 Mar 2019, 04:25
by mjs
I have what I suspect is a newbie question regarding writing perl modules for use in the polymake shell. Here is a minimal broken example that demonstrates my problem. I save the following in a file "example.pm" in my working directory:

Code: Select all

package example; use strict; use warnings; use application "polytope"; sub my_test_routine { my $v = new Vector([1,0,0]); return $v; } 1;
In the polymake shell, I do the following:

Code: Select all

polytope > use example; polytope > $v = example::my_test_routine();
And then I get the error

polymake: ERROR: Can't locate object method "new" via package "Vector" at example.pm line 7.

Is there an easy fix for this?

Re: Using modules with polymake

Posted: 16 Mar 2019, 16:25
by gawrilow
Either load your code with "script" instead of "use", or put the line "package example" after "use application". This restriction is unfortunate but currently unavoidable.

BTW "use warnings" and "use strict" are redundant, all scripts in polymake are always interpreted this way.

Re: Using modules with polymake

Posted: 26 Mar 2019, 10:23
by mjs
This worked. Thank you for your help!