textuml icon indicating copy to clipboard operation
textuml copied to clipboard

Specify a clone() operation in Basic/Object/Value

Open abstratt opened this issue 7 years ago • 1 comments

Specify a clone() operation in Basic/Object/Value, which performs a shallow clone (or deep clone)?

abstratt avatar Aug 21 '18 19:08 abstratt

A challenge here is how to declare the return type of this operation. The language currently does not allow for covariant return types.

Looks like something better done via a function:

function clone<T>(toClone : T) : T;

or a special clone operator, such as have with new, meaning an object creation where properties are initialized with the source object.

abstratt avatar Sep 12 '18 15:09 abstratt