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

Sg/display func #233

Merged
merged 1 commit into from
May 16, 2019
Merged

Sg/display func #233

merged 1 commit into from
May 16, 2019

Conversation

sebasguts
Copy link
Contributor

Currently based on
#232 and gap-system/gap#3438

@codecov
Copy link

codecov bot commented May 6, 2019

Codecov Report

Merging #233 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #233   +/-   ##
=======================================
  Coverage   75.38%   75.38%           
=======================================
  Files           5        5           
  Lines         459      459           
=======================================
  Hits          346      346           
  Misses        113      113

@sebasguts sebasguts force-pushed the sg/DisplayFunc branch 3 times, most recently from 661f499 to 35eee8c Compare May 8, 2019 09:48
Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase

function Display(x::MPtr)
local_var = "julia_gap_display_tmp"
AssignGlobalVariable(local_var,x)
xx = EvalStringEx("Display($local_var);")[1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, it shouldn't be necessary to jump through such hoops. With that, I don't mean there is a way to avoid it right now (sadly, I fear there is none, so your hack is needed for now). But rather, that there should be a way. At least for Print, you can use PrintTo to redirect to a file or stream. So perhaps we need to add ViewTo and DisplayTo` functions to GAP. And/or provide a more general mechanism to redirect the output.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GAP package GAPDoc provides functions StringPrint and StringView (based on PrintTo1) which create strings for a given object that describe the Print and View output for this object, respectively.
An analogous StringDisplay could be provided, and these functions could be taken for producing the strings needed by Julia and Jupyter notebooks and the like, at least temporarily.

It is not obvious for me which strings one really wants for a given GAP object.
The above functions create strings with line breaks according to the current line length.
In the case of Display, I would say that this is fine:
Those objects for which Display is most interesting require a two-dimensional formatting,
and the line length is needed to define the context.

In the case of View and Print, one can alternatively produce one string with line breaking hints \< and \> for a given object, and postpone the actual formatting, in the sense of responsive design.
(After the recent change #3440 in gap-system/gap, I am more optimistic that ViewString can work as a long-term solution.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would honestly prefer to use something like DisplayString, which is already defined in GAP, but does not really provide me with the strings I really need.

This function is for a very special case only, i.e., using it from the Jupyter Notebook with Julia kernel. Of course, we can think about a different solution, and implement all kinds of backend for it in GAP, or even cleanup the whole output mess in GAP. But imho this function has a very huge advantage over all the stuff you propose: It works right now.

So, while all your comments are totally valid, and this function is really not nicely designed or anything, I would suggest we merge it now, and then later go through the whole shebang of doing what you propose. I would happily write a DisplayTo function for GAP, but keep in mind that this might be a non-trivial task.

Copy link
Contributor Author

@sebasguts sebasguts May 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fingolfin I have to apologize a bit for my whitty comment. I did not read that you also probably not think there is a better ad-hoc solution in GAP. So okay, I think we overall agree that this is horrible and should not be done this way, but it is the only way to do it right now.

On the other hand, as mentioned above, the function is really for a very specific case, and once a better solution comes around, we can just change it.

So overall, I am sorry that I actually read it in the wrong way, namely that it should be done differently. But now reading the comment again, it seems like we both agree on that stuff.

@sebasguts
Copy link
Contributor Author

I updated this PR to the final version of gap-system/gap#3438

fingolfin
fingolfin previously approved these changes May 16, 2019
Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the random placement of whitespace, this looks fine to me. Perhaps add a FIXME/TODO comment in Display to say that ultimately we would like to get rid of that EvalStringEx call?

pkg/GAPJulia/JuliaInterface/julia/ccalls.jl Outdated Show resolved Hide resolved
pkg/GAPJulia/JuliaInterface/julia/ccalls.jl Outdated Show resolved Hide resolved
pkg/GAPJulia/JuliaInterface/julia/ccalls.jl Outdated Show resolved Hide resolved
pkg/GAPJulia/JuliaInterface/julia/gap.jl Outdated Show resolved Hide resolved
@sebasguts sebasguts dismissed stale reviews from fingolfin via 46e73c0 May 16, 2019 09:10
fingolfin
fingolfin previously approved these changes May 16, 2019
@sebasguts
Copy link
Contributor Author

Added a comment and merged your suggestions. Thank you :)

@sebasguts sebasguts merged commit 61ff748 into oscar-system:master May 16, 2019
@sebasguts sebasguts deleted the sg/DisplayFunc branch May 17, 2019 09:23
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

Successfully merging this pull request may close these issues.

3 participants