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

doc: improve doc of NewConstructor #1391

Merged
merged 3 commits into from
Jun 7, 2017
Merged

Conversation

ssiccha
Copy link
Contributor

@ssiccha ssiccha commented Jun 6, 2017

Constructors behave a bit differently under the method selection
than other operations but the documentation did not describe this.

Constructors behave a bit differently under the method selection
than other operations but the documentation did not describe this.
@fingolfin
Copy link
Member

While at it, maybe also hook up the DeclareConstructor documentation to the manual? I.e.

diff --git a/doc/ref/create.xml b/doc/ref/create.xml
index 224cccaa7..8a82fb7e5 100644
--- a/doc/ref/create.xml
+++ b/doc/ref/create.xml
@@ -1182,6 +1182,7 @@ See also Section <Ref Sect="More About Global Variables"/>.
 <#Include Label="DeclareProperty">
 <#Include Label="DeclareFilter">
 <#Include Label="DeclareOperation">
+<#Include Label="DeclareConstructor">
 <#Include Label="DeclareGlobalFunction">
 <#Include Label="DeclareGlobalVariable">
 <#Include Label="InstallValue">

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.

Thanks, I think it's great this is being addressed. I really would like @stevelinton to comment, though.

Also, see issue #601.

Could you also please clarify what the basis for your text is? Did you analyze the code implementing constructor? Did you perform experiments to confirm your findings? If so, could you perhaps including them, say in an example, as suggested in my detailed feedback comments?

Finally,

## <A>args-filts</A><M>[i]</M>. Additionally a constructor expects the first
## argument to be a filter to then select a method to construct an object.
## of <A>cons</A>. Namely the number of arguments must be equal to the length
## of <A>args-filts</A>, and the <M>i</M>-th argument
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 early wrapping? That causes an unnecessary diff (thus making it a little bit harder to review this PR), and I see no good reason for doing it?

## lies in the filter <A>args-filts</A><M>[i]</M>.
## <Ref Func="InstallMethod"/> must require that
## the <M>i</M>-th argument lies in the filter <A>args-filts</A><M>[i]</M>
## for <M>i \neq 1</M>.
Copy link
Member

Choose a reason for hiding this comment

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

Again, weird re-wrapping -- now I have to carefully check what you really changed :-(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I just thought it would look cleaner in the end. Didn't think about the weird-looking diffs it would introduce. I'll keep that in mind in the future, thanks. :)

Copy link
Member

Choose a reason for hiding this comment

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

Luckily I can use http://www.jefftk.com/icdiff on my local computer to make it better, but the easier it is to already review in the browser, the faster you'll get meaningful feedback

lib/oper.g Outdated
## is chosen, since the rank is computed by taking <M>-1</M> times the ranks
## of the involved filters.
## <P/>
## Imagine wanting to construct a new IsMatrixObject without caring
Copy link
Member

Choose a reason for hiding this comment

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

"Imagine" ? So, is this an example? Then I'd start with "For example" to make that clear.

Also, don't you mean IsMatrixObj?

lib/oper.g Outdated
## Imagine wanting to construct a new IsMatrixObject without caring
## explicitly in which representation it is created.
## &GAP; then chooses a filter whis is <Q>as close</Q> to
## IsMatrixObject as possible.
Copy link
Member

Choose a reason for hiding this comment

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

This leaves me with more questions. E.g. why wouldn't I just use IsMatrixObj? Why would I only want to be "as close" as possible?
How about giving an actual example? Or perhaps declare a constructor, then install 2-3 methods, and document which of them is used for various (also given) example invocations?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think "close" is slightly the wrong word. Method selection in this case will choose a constructor which guarantees to produce an object in IsMatrixObj. All other things being equal it will choose the one that promises the fewest extra filters on the grounds that that is presumably easiest to do.

Copy link
Contributor Author

@ssiccha ssiccha Jun 6, 2017

Choose a reason for hiding this comment

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

Ok, I'll get on that.

@fingolfin fingolfin added topic: documentation Issues and PRs related to documentation kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements labels Jun 6, 2017
@ssiccha
Copy link
Contributor Author

ssiccha commented Jun 6, 2017

The corresponding code is INSTALL_METHOD_FLAGS in oper1.g:128 We stumbled upon this when looking at the NewMatrix code.

@codecov
Copy link

codecov bot commented Jun 6, 2017

Codecov Report

Merging #1391 into master will decrease coverage by 0.11%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #1391      +/-   ##
==========================================
- Coverage   62.11%      62%   -0.12%     
==========================================
  Files        1028     1028              
  Lines      349854   349853       -1     
  Branches    14223    14223              
==========================================
- Hits       217315   216922     -393     
- Misses     128970   129345     +375     
- Partials     3569     3586      +17
Impacted Files Coverage Δ
lib/oper.g 75.51% <ø> (ø) ⬆️
src/c_random.c 73.7% <0%> (-25.9%) ⬇️
src/sortbase.h 58.24% <0%> (-22.53%) ⬇️
src/vecffe.c 48.61% <0%> (-19.91%) ⬇️
src/vector.c 84.21% <0%> (-12.29%) ⬇️
src/weakptr.c 70.33% <0%> (-11.87%) ⬇️
src/listfunc.c 67.08% <0%> (-4.63%) ⬇️
src/intfuncs.c 87.93% <0%> (-3.45%) ⬇️
lib/random.gi 73.07% <0%> (-2.89%) ⬇️
src/listoper.c 70.71% <0%> (-2.85%) ⬇️
... and 18 more

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.

OK, that seems better. I have, however, not verified that anything in here is correct (not that I doubt it)

@ChrisJefferson ChrisJefferson merged commit 8dd0b93 into gap-system:master Jun 7, 2017
@ssiccha ssiccha mentioned this pull request Sep 14, 2017
@olexandr-konovalov olexandr-konovalov added the release notes: not needed PRs introducing changes that are wholly irrelevant to 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
kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes topic: documentation Issues and PRs related to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants