GAP.jl
GAP.jl copied to clipboard
`GAP.evalstr` eats up all output
Consider this:
julia> GAP.evalstr("Display(1);")
julia>
There is no output because GAP.evalstr is currently implemented using GAP.evalstr_ex, which deliberately redirects GAP's stdout into a string:
julia> GAP.evalstr_ex("Display(1);")
GAP: [ [ true,, false,, "1\n" ] ]
Perhaps we should just print this captured stdout? Or perhaps we should implement GAP.evalstr differently. Right now it is implemented using GAP_EvalString which in turn invokes READ_ALL_COMMANDS(instream, False, True, viewObjFunc); -- the first False turns off echo mode; perhaps we should directly invoke GAP.Globals.READ_ALL_COMMANDS, e.g.
function myevalstr(s::String)
input = GAP.Globals.InputTextString(GAP.Obj(s))
view = GAP.Globals.EvalString(g"function(x) ViewObj(x); Print(\"\\n\"); end")
res = GAP.Globals.READ_ALL_COMMANDS(input, true, false, view);
end
I guess it also depends a bit on the desired semantics... Which we should decide on and document more carefully?
It really depends on what we want to achieve. Concerning GAP.evalstr("Display(1);"), GAP's Display has no return value, just a side effect, hence GAP.evalstr returns nothing.
GAP.evalstr_ex covers both aspects, return value and output, like in the following example.
julia> GAP.evalstr_ex( "1 + 2;" )
GAP: [ [ true, 3, false,, "3" ] ]
julia> GAP.evalstr_ex( "1 + 2;;" )
GAP: [ [ true, 3, true,, "" ] ]