Closed AjaniBilby closed 3 years ago
This would not affect the type signature but instead allows more condensed code to be written and the compiler to remove unnecessary clones.
Example of somewhat condensed code
class String { fn Length(this: #String): u64 { return this.size - cast#[u64](1); } fn Clone(this: #String): String { // Initiliase the data structure let out = Blank#[String](); out.data = Memory.Alloc(this.size); out.size = this.size; // Copy the blob data to the new allocation Memory.Copy($out.data, $this.data, this.size, false); return out; } } fn puts(str: #String) { puts(str.data); }
This would not affect the type signature but instead allows more condensed code to be written and the compiler to remove unnecessary clones.
Example of somewhat condensed code