Setting array length to 0 discards reserved allocation?
via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jul 29 01:41:46 PDT 2014
On Tuesday, 29 July 2014 at 07:46:34 UTC, Andrew Godfrey wrote:
> On Sunday, 27 July 2014 at 05:51:46 UTC, Jakob Ovrum wrote:
>> On Saturday, 26 July 2014 at 23:06:02 UTC, Andrew Godfrey
>> wrote:
>>> Thereafter can come sub-slice examples and so on.
>>> Does this make sense?
>>
>> Yes, the reference documentation is pretty terrible with
>> naming of various array concepts.
>>
>> IIRC, when this was discussed in the past, a majority seemed
>> to be in favour of using "slice" and "dynamic array" for their
>> respective concepts instead of the current situation, but I
>> also remember there was some opposition (for reason I can't
>> remember). A pull request updating the documentation to use
>> slice/dynamic array might weed them out ;)
>
> 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".
More information about the Digitalmars-d
mailing list