motoko-base icon indicating copy to clipboard operation
motoko-base copied to clipboard

Method naming should be consistent wrt `Mut` or `Var`.

Open matthewhammer opened this issue 2 years ago • 1 comments

Motoko base library is internally inconsistent about how it names methods that operate with mutable arrays.

In some places, it uses Var to distinguish these, and other places, Mut.

For instance, a current grep of the source files shows these places:

Var

Array.mo:  public func tabulateVar<A>(size : Nat,  gen : Nat -> A) : [var A] {
Buffer.mo:    public func toVarArray() : [var X] {
Buffer.mo:  public func fromVarArray<X>(elems : [var X]) : Buffer<X> {
List.mo:  public func fromVarArray<A>(xs : [var A]) : List<A> =
List.mo:  public func toVarArray<A>(xs : List<A>) : [var A] =

Mut

Blob.mo:  public let fromArrayMut : [var Nat8] -> Blob = Prim.arrayMutToBlob;
Blob.mo:  public let toArrayMut : Blob -> [var Nat8] = Prim.blobToArrayMut;
Iter.mo:  public func fromArrayMut<A>(xs : [var A]) : Iter<A> {
Iter.mo:  public func toArrayMut<A>(xs : Iter<A>) : [var A] {

matthewhammer avatar Jun 17 '22 15:06 matthewhammer

Since the keyword is var, that may be more consistent to use?

rossberg avatar Jun 20 '22 14:06 rossberg