it seems that escaping quotes does not help when applying function construction from string iteratively:
we also have to escape backslashes:
Code:
LIB("findifs.lib");
proc foo ()
{
string bar = "sdfs";
return (0);
}
foo;
string fooStr = string(foo);
fooStr;
def fooStrMod = replace(fooStr,"\"","\\\"");
string cmd = "proc bar( )
{
proc rfoo=\""+fooStrMod+"\";
return (rfoo());
}";
cmd;
execute (cmd);
bar();
string barStr = string(bar);
barStr;
def barStrMod = replace(barStr,"\\","\\\\");
def barStrMod2 = replace(barStrMod,"\"","\\\"");
cmd = "proc foobar( )
{
proc rbar=\""+barStrMod2+"\";
return (rbar()+2);
}";
cmd;
execute (cmd);
foobar();
does the principle of dump differ?
If this isn't gonna work in a generic way (without writing a parser for the Singular language),
the closest approach to compose generator functions without parameters from other functions
would be to introduce intermediate global functions (randomly named):
github.com/Singular/Sources/issues/558