On Tuesday, 29 July 2014 at 08:41:48 UTC, Marc Schütz wrote:
On Tuesday, 29 July 2014 at 07:46:34 UTC, Andrew Godfrey wrote:

I gave this a try, and overall it looks like an improvement, but I think we need another name than "slice". The reason is that the slice operator is a distinct thing and interacts with the "slice" in strange ways. When I next get time I'll try updating it to use the term "array reference". That is:

int[] a; // defines an array reference, a
int[3] b;
a = b[1..3]; // updates the array reference a to refer to a slice of b

IMO slice fits quite well for both. `b[1..3]` is a slice (or refers to one?), and `a` is, too. After the assignment, both slices are equal. But I see that there is an ambiguity when we talk about "copying a slice", which could also be interpreted as "copying what the slice refers to".

That wasn't meant to be a motivating example.
The totality of what I have so far is really what makes me think this - it's too big to share here, but I suppose I could submit a PR for rejection?

Here's an attempt at a short motivating example:

    int[3] a = [1, 0, -1];
    int[] b = a;
    int[] c = new int[4];

    b[] = c[1..4];
    assert(a[2] == 0);

// Using the proposed 'slice' term, an exhaustive description of the above operation is: // This copies a slice of the slice c onto the slice b (which refers to a).
    //
// If we instead call b and c "array references", the description reads: // This copies a slice of the array referenced by c, onto the array referenced by b (which is a).

Reply via email to