How would you name a read-only type whose mutable ...
# naming
y
How would you name a read-only type whose mutable version already has a basic name? Specifically, we have some
VecX
types that are mutable vectors, and I'm struggling to find a name for a new read-only Vector type that they should implement. I'm thinking maybe
ReadOnlyVecX
but it seems to be too long. The issue is that changing the name of
VecX
to
MutableVecX
would be a big change, especially considering that most Vec-based code would be using mutability, while the read-only versions likely will be used to specify that method parameters and results can't be modified. I also thought maybe
VecXVals
could be an apt name since the interface would really only define the `val`s required to represent that vector, but it still doesn't seem elegant enough
e
ReadOnlyVecX
or
ImmutableVecX
imo. Its not really that long imo, and IDEs should complete most of it for you anyway.
y
I thought of
ImmutableVecX
but it's misleading because the type won't actually be immutable.
r
Depending on the intended use case of the read only variant, something like
VecXView
could work (or another word like preview, window, copy, etc).
y
Funny that you suggested that. I've been thinking of adding
VecXView
as a way of getting a live-updated vector. The more I think about it, the better the name works. I could then have
VecXMutableView
for the read-write version of that type that basically internally holds a bijection of sorts to convert back and forth. I think I'm gonna go with
VecXView
unless I get an epiphany of a better name. Thank you!
m
To keep the analogy with stdlib you could make `Vec`and `MutableVec : Vec`(as with
List
and
MutableList
)
e
IMO you should pick which bits of
Copy code
UnmodifiableFoo
 |- MutableFoo
 \- ImmutableFoo
     \- PersistentFoo
you want, and then maybe give a shorter name to the most common one of them
e.g. stdlib only has
UnmodifiableList
(which it calls
List
) and
MutableList
, with `ImmutableList`/`PersistentList` being supplied by
kotlinx.immutable
Scala has
Copy code
scala.collection.Seq
  |- scala.collection.mutable.Seq
  \- scala.collection.immutable.Seq
which is also a choice you could make