Is Buffer.clone a deep clone?

Motoko is a sufficiently high-level language that there isn’t an observable difference between by-value vs by-reference. That’s an implementation detail entirely. The only thing that’s semantically visible is that a value containing a mutable member (e.g. a var field or var array element) is never implicitly copied.

FWIW, class is completely immaterial in that regard as well. It is merely syntactic sugar for a regular function that returns an object, plus a type definition.

3 Likes