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

Add String method for functions #1591

Merged
merged 1 commit into from
Aug 18, 2017

Conversation

stevelinton
Copy link
Contributor

A bit of a hack as it uses string streams rather than modifying the kernel

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.

Besides nitpicks, just one remark: It would be nice if a test was added for this (so that merging this does not decrease coverage).

lib/function.gi Outdated
@@ -59,3 +59,16 @@ function(func)
Append(result, " ) ... end");
return result;
end);


InstallMethod(String, "for a function, using string stream", [IsFunction] ,
Copy link
Member

Choose a reason for hiding this comment

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

remove space before comma?

lib/function.gi Outdated
function(fun)
local s, str;
s := "";
str := OutputTextString(s,true);
Copy link
Member

Choose a reason for hiding this comment

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

insert space after comma?

lib/function.gi Outdated


InstallMethod(String, "for a function, using string stream", [IsFunction] ,
function(fun)
Copy link
Member

Choose a reason for hiding this comment

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

Why this odd indentation?

@codecov
Copy link

codecov bot commented Aug 17, 2017

Codecov Report

Merging #1591 into master will decrease coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #1591      +/-   ##
==========================================
- Coverage   63.98%   63.97%   -0.01%     
==========================================
  Files         995      995              
  Lines      325334   325344      +10     
  Branches    13032    13032              
==========================================
- Hits       208155   208148       -7     
- Misses     114381   114394      +13     
- Partials     2798     2802       +4
Impacted Files Coverage Δ
lib/function.gi 77.77% <100%> (+5.05%) ⬆️
lib/queue.g 66.4% <0%> (-3.2%) ⬇️
src/permutat.c 74.34% <0%> (-1.27%) ⬇️
src/hpc/traverse.c 77.9% <0%> (-0.78%) ⬇️
hpcgap/lib/object.gi 38.75% <0%> (-0.63%) ⬇️
lib/grpmat.gi 67.91% <0%> (-0.56%) ⬇️
src/listfunc.c 77.37% <0%> (-0.18%) ⬇️
src/funcs.c 72.49% <0%> (ø) ⬆️
src/hpc/threadapi.c 35.12% <0%> (+0.09%) ⬆️
src/streams.c 46.38% <0%> (+0.35%) ⬆️
... and 1 more

@stevelinton
Copy link
Contributor Author

@fingolfin I've addressed your comments. I've also made the original method a method for DisplayString. The String method now returns a version with normalised whitespace, which is
ugly for large functions, but I think more appropriate for String.

lib/function.gi Outdated
str := OutputTextString(s, true);
PrintTo(str, fun);
CloseStream(str);
Add(s,'\n');
Copy link
Member

Choose a reason for hiding this comment

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

Space after comma?

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.

This seems good to me (though I have two super-nitpicks, but it's also OK to ignore them; I just won't be the one to hit merge while they are in, but steve or somebody else is most welcome to merge this)

lib/function.gi Outdated
s := "";
str := OutputTextString(s, true);
PrintTo(str, fun);
CloseStream(str);
Copy link
Member

Choose a reason for hiding this comment

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

Super-nitpick, I am not expecting any action on it, but needed to get it off my chest: When I see "str" I think "string", but here it is "stream", while "s" is a string... This function is short, and so it's harmless, but I'd still rename at least one of them (probably str to stream, as I see strings more more often than streams, at least in GAP code)

A bit of a hack as it uses string streams rather than modifying the kernel
Includes tests
@stevelinton
Copy link
Contributor Author

Fixed nitpicks. Just wait for the tests to make sure I didn't break something.

@markuspf markuspf merged commit c78bb4c into gap-system:master Aug 18, 2017
@olexandr-konovalov olexandr-konovalov added this to the GAP 4.9.0 milestone Jan 20, 2018
@olexandr-konovalov olexandr-konovalov added the release notes: added PRs introducing changes that have since been mentioned in the release notes label Jan 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: added PRs introducing changes that have since been mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants