Hello Stavros,
> Well, let's hear your proposals for (a) the user-visible semantics you
> want and (b) the efficient implementation mechanism to support them.
About (b), I believe a copy on write scheme is workable.
I don't see how to avoid copying the structural bits (number
of rows & columns, etc), but I believe it will usually be possible
to avoid copying the storage area unless necessary.
A difficulty that I see at present with copy on write is that
I don't know how to detect writes through anonymous
references (i.e., not associated with a symbol).
About (a), I can see a couple of possibilities.
For brevity I've written "creates a copy" for "appears to
create a copy" throughout. Also, I've only mentioned matrices
but we can also consider lists and maybe other object types.
(1) Assigning a matrix creates a copy.
Passing a matrix as a function argument creates a copy.
Extracting rows, columns, and submatrices creates copies.
Pasting matrices together creates copies.
Assignment to a matrix element modifies the matrix.
(2) Extracting rows, columns, and submatrices creates copies.
Pasting matrices together creates copies.
Assignment to a matrix element modifies the matrix.
A justification for (2) is that extracting and pasting together
create different objects, while assignment and passing a
function argument don't.
I think I like (2) better but there's certainly no need to decide now.
For what it's worth,
Robert Dodier