Skip to content

Commit

Permalink
Add Display method for functions
Browse files Browse the repository at this point in the history
This fixes a problem where printing functions with long literals would
wrap those literals badly. As an example, before this fix, we got:

    gap> SizeScreen([60,100]);;
    gap> Display(f->12345678901234567890123456789012345678901234567890123456789012345678901234567890);
    function ( f )
        return
         12345678901234567890123456789012345678901234567890123\
    \
    456789012345678901234567890;
    end

With this fix, we get:

    gap> SizeScreen([60,100]);;
    gap> Display(f->12345678901234567890123456789012345678901234567890123456789012345678901234567890);
    function ( f )
        return
         12345678901234567890123456789012345678901234567890123\
    456789012345678901234567890;
    end

Fixes #3205
  • Loading branch information
fingolfin committed Jan 22, 2019
1 parent 40b2048 commit 81e2bb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 52 deletions.
5 changes: 5 additions & 0 deletions lib/function.gi
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ function(func)
return result;
end);

InstallMethod(Display, "for a function", [IsFunction and IsInternalRep],
function(fun)
Print(fun, "\n");
end);

InstallMethod(DisplayString, "for a function, using string stream", [IsFunction and IsInternalRep],
function(fun)
local s, stream;
Expand Down
52 changes: 0 additions & 52 deletions tst/testinstall/float.tst
Original file line number Diff line number Diff line change
Expand Up @@ -426,31 +426,18 @@ gap> Display(f);
function ( )
return
2.11111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
11111111111111111111_;
end
gap> f := {} -> 2.11111111111111111111111111111111111111111111111111111111111\
Expand All @@ -473,31 +460,18 @@ gap> Display(f);
function ( )
return
2.11111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
11111111111111111111_l;
end
gap> f := {} -> 2.11111111111111111111111111111111111111111111111111111111111\
Expand Down Expand Up @@ -551,31 +525,18 @@ gap> Display(g);
function ( )
return
2.11111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
11111111111111111111;
end
gap> g();
Expand All @@ -598,31 +559,18 @@ gap> Display(g);
function ( )
return
2.11111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
\
11111111111111111111l;
end
gap> g();
Expand Down

0 comments on commit 81e2bb3

Please sign in to comment.