Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GAP.evalstr eats up all output #895

Open
fingolfin opened this issue Jun 15, 2023 · 1 comment
Open

GAP.evalstr eats up all output #895

fingolfin opened this issue Jun 15, 2023 · 1 comment

Comments

@fingolfin
Copy link
Member

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?

@ThomasBreuer
Copy link
Member

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,, "" ] ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants