Skip to content

Commit

Permalink
ExtRepOfObj for IsLetterAssocWordRep: return mutable list
Browse files Browse the repository at this point in the history
... 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]`.
  • Loading branch information
fingolfin committed Sep 26, 2024
1 parent 2a7cf16 commit 67e2326
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/wordlett.gi
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ local i,r,elm,len,g,h,e;
end);

InstallMethod(ExtRepOfObj,"assoc word in letter rep",true,
[IsAssocWord and IsLetterAssocWordRep],0,ERepLettWord);
[IsAssocWord and IsLetterAssocWordRep],0,x->ShallowCopy(ERepLettWord(x)));

InstallMethod(NumberSyllables,"assoc word in letter rep",true,
[IsAssocWord and IsLetterAssocWordRep],0,
Expand Down
4 changes: 2 additions & 2 deletions tst/testinstall/wordrep.tst
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ true
#
gap> f:= FreeGroup(IsLetterWordsFamily,4);;
gap> IsMutable(ExtRepOfObj(f.1));
false
true
gap> IsMutable(ExtRepOfObj(f.1));
false
true

#
gap> STOP_TEST("wordrep.tst");

0 comments on commit 67e2326

Please sign in to comment.