From 67e2326f20a6fd0a250ea06382d9e5d64d745ddb Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 26 Sep 2024 10:29:20 +0200 Subject: [PATCH] ExtRepOfObj for IsLetterAssocWordRep: return mutable list ... 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]`. --- lib/wordlett.gi | 2 +- tst/testinstall/wordrep.tst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/wordlett.gi b/lib/wordlett.gi index 0456d758a4..75d0c5ba01 100644 --- a/lib/wordlett.gi +++ b/lib/wordlett.gi @@ -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, diff --git a/tst/testinstall/wordrep.tst b/tst/testinstall/wordrep.tst index c8844d876c..d4d8b903a4 100644 --- a/tst/testinstall/wordrep.tst +++ b/tst/testinstall/wordrep.tst @@ -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");