New PlainListCopy
vs. AsPlist
: unify?
#4357
Labels
kind: discussion
discussions, questions, requests for comments, and so on
PlainListCopy
vs. AsPlist
: unify?
#4357
In PR #4332, the GAP library function
PlainListCopy
(which has existed for many years but was undocumented) was fixed and enhanced, for use in PR #4331.Today I came upon the GAP library operation
AsPlist
which seems to serve a very similar purpose, with one key difference: if the input is already a plain list, it just returns that, i.e., not a copy. That's also what the documentation of that function says (but note that it is not documented in the GAP reference manual, i.e., it is "undocumented" for purposes of whether we made any binding promises about it or not). Also, no package I have access to usesAsPlist
Note we already have a bunch of "pairs" like
List/AsList
,Set/AsSet
; typically, the first function returns a mutable object, theAs*
version an immutable one. Based on that, it is also strange thatAsPlist
returns something mutable...How about the following:
PlainListCopy
toPlist
(and/or have one be a synonym of the other)AsPlist
to return an immutable copy insteadAsPlist
should be a kernel operation or aAsPlistOp
)On the other hand, it may be useful for efficiency reasons to have a function like the current
AsPlist
, i.e., which returns the original input if it was a plist all along. But looking at the GAP library, I don't really think it matters much if at all to the existing use cases, which mostly look like this:AsSSortedListList(AsPlist(xxx))
. So yeah, ifxxx
is plain list, we save a bit, but typically the relevant methods already have a special case forIsPlistRep
, e.g.Thoughts? It would be good to resolve this before the GAP 4.12.0 release, so that we never announce
PlainListCopy
if we decide to rename it.The text was updated successfully, but these errors were encountered: