-
Notifications
You must be signed in to change notification settings - Fork 161
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
Rewrite and officially document PlainListCopy
#4332
Conversation
Suggested release notes: Add function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for separating this into a separate PR. I've got a few questions/suggestions.
lib/list.gd
Outdated
## <ManSection> | ||
## <Func Name="PlainListCopy" Arg='list'/> | ||
## | ||
## <Description> | ||
## This operation returns a list equal to its argument, in a plain list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to document that the returned list is guaranteed to be an actual copy (i.e. it's equal but not IsIdenticalObj
)
af88a81
to
1ee92e6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making those changes. Here's a concrete suggestion for how you could implement the remaining comment from my first review.
lib/list.gd
Outdated
## This function returns a list equal to its argument, in a plain list | ||
## representation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## This function returns a list equal to its argument, in a plain list | |
## representation. | |
## This function returns a new list that is equal to its argument | |
## and is in the plain list representation. |
## This is intended for use in certain rare situations, | ||
## such as before objectifying. | ||
## Normally, <C>ConstantAccessTimeList</C> should be enough. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exists and was a typo for ConstantTimeAccessList
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said, I don't think this sentence was helpful, so I am fine with removing it :-)
I'm going to go though all the callers of PlainListCopy. Firstly, there a number of lines of the form The function PLAIN_SL tries to convert a sparse list in place to a plain list. It does: CLONE_OBJ(sl, PlainListCopy(sl));, so once again it doesn't matter if PlainListCopy returns the original, or a copy. I checked this function does work correctly if PlainListCopy does, or doesn't return a copy. This function is very weird looking, but no need to change it today. Finally, tuples.gi calls PlainListCopy on a newly created list. I imagine here it is because List can "be clever" and return a weird type of list. |
I mildly disagree that The whole "sparse list" code is undocumented, unused, not loaded, and AFAIK incomplete. We may as well delete it (opened PR #4336). I really don't understand why it is used in Finally, no packages seem to be using those. Good! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me but perhaps review the couple comments by Wilf and myself, and decide if you want to do anything about any of them
I took the liberty and adjusted the suggested release notes. Feel free to revise further. |
f58748e
to
3ee9a09
Compare
## | ||
DeclareOperation("PlainListCopyOp", [IsSmallList]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we say here that it is a kernel function, in case people wonder where to find it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I am also fine with merging as-is, just wondering)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've now moved the documentation inline in the doc XML, because it was weird here -- but maybe that's a bad idea too. We could start scanning C code for GAPDoc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In doc/ref/makedocreldata.g
we already list src/sysfiles.c
and could add more. I would in fact suggest that we change that file to not hardcode the list of files to scan, but rather to scan all files src/*.{c,h}
, lib/*.{gd,gi}
, etc., but of course that goes way beyond the scope of this PR ;-)
Sorry I must have touched my trackpad really awkwardly and closed the PR and posted this comment before I was finished!! Whoops. The CI failures... In
and in
Which seems a bit harder to fix, if |
3ee9a09
to
ca6016c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still looks good to me, please merge at will
PlainListCopy
After looking at uses of PlainListCopy, I decided the internal kernel function PLAIN_LIST_COPY does everything it is supposed to do, and the best idea was to delegate to it.
While PlainListCopy could (by it's docs) sometimes copy and sometimes not, none of the uses we relying on the behaviour of not copying, or changing the original.
This mainly involved removing the now unused PlainListCopyOp.
This PR is required for #4331