evylang / todo

0 stars 0 forks source link

Spec: Update Index and Slice section with explicit callout to copying composite types #92

Open Rossiar opened 3 months ago

Rossiar commented 3 months ago

I don't think the spec makes the behaviour of copy by reference clear when it says:

A slice is a way to access portions of an array or a string. It is a substring or subarray that is copied from the original array or string.

It would be good to add an example to this section of the spec to highlight that composite types are copied by reference. Something like:

x := [[1 2] [3 4]]
y := x[:]
y[0] = [8 9]
print "x:" x
print "y:" y
---
x: [[8 9] [3 4]]
y: [[8 9] [3 4]]