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

ExtRepOfObj for IsLetterAssocWordRep: return mutable list #5805

Merged

Conversation

fingolfin
Copy link
Member

... as this is how GAP behaved for years, and also many (most?) other ExtRepOfObj implementations also return a mutable list. So it seems plausible to mimic that.

At the same time, keep the return value of ERepLettWord immutable, to avoid many needless copies of a list in code that does things like Length(ERepLettWord(w)) or ERepLettWord(w)[2*n-1].

Addresses fallout from #5802 in an arguably better way. So semigroups wouldn't have to change (CC @james-d-mitchell) and groupoids could roll back its changes (CC @cdwensley), though it would also be safe for it to stay as it is (though potentially a teeny tiny bit less efficient).

Sorry for the back and forth folks.

... as this is how GAP behaved for years, and also many (most?)
other `ExtRepOfObj` implementations also return a mutable list.
So it seems plausible to mimic that.

At the same time, keep the return value of `ERepLettWord` immutable,
to avoid many needless copies of a list in code that does things
like `Length(ERepLettWord(w))` or `ERepLettWord(w)[2*n-1]`.
@fingolfin fingolfin added topic: library release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes labels Sep 26, 2024
Copy link
Contributor

@ThomasBreuer ThomasBreuer left a comment

Choose a reason for hiding this comment

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

I agree with the argument that GAP did in fact return a mutable ExtRepOfObj result in this situation, and that there are packages which use this fact.
(Well, actually these packages were just lucky that they did not run into situations where the cache is used.)

I think that it is in general good that the mutability of results of ExtRepOfObj can depend on what the method in question does:

If just some internally stored data are returned then this object has to be immutable, and automatically making a copy (like in the current pull request) is unnecessary. And if an independent new object gets constructed by ExtRepOfObj, it is unnecessary to make it immutable.
If the return value is mutable then users know that it is safe to change it, if the return value is immutable then users who want to change it know that they have to make a copy first.

@fingolfin fingolfin merged commit fa2aafa into gap-system:master Sep 29, 2024
30 checks passed
@fingolfin fingolfin deleted the mh/ExtRepOfObj-IsLetterAssocWordRep branch September 29, 2024 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes topic: library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants