On 6/7/17 3:56 AM, Biotronic wrote:
On Wednesday, 7 June 2017 at 05:43:06 UTC, ag0aep6g wrote:
[snip]
It seems to me this is a topic worthy of a more in-depth article. If
only I felt up to that. :p
Your understanding and explanation is excellent actually!
When you create a slice 'a' in D
On Wednesday, 7 June 2017 at 05:43:06 UTC, ag0aep6g wrote:
[snip]
It seems to me this is a topic worthy of a more in-depth article.
If only I felt up to that. :p
When you create a slice 'a' in D (with the current GC and
druntime, at least), what happens behind the scenes is the
allocator c
On Wednesday, June 07, 2017 07:43:06 ag0aep6g via Digitalmars-d-learn wrote:
> You understand the spec to say that because `foo.capacity` is 15 at one
> point, you should then be able to put 15 elements into `foo` without
> relocation. And what `bar` does in the meantime shouldn't matter.
>
> I don
On 06/07/2017 12:12 AM, Ali Çehreli wrote:
On 06/06/2017 12:13 PM, Jesse Phillips wrote:
> On Monday, 5 June 2017 at 23:17:46 UTC, Ali Çehreli wrote:
>> auto a = [ 1, 2, 3, 4 ];
>> auto b = a;
[...]
The only issue remaining for me is the part that you've quoted:
Jesse Phillips did
On 06/06/2017 12:13 PM, Jesse Phillips wrote:
> On Monday, 5 June 2017 at 23:17:46 UTC, Ali Çehreli wrote:
>> auto a = [ 1, 2, 3, 4 ];
>> auto b = a;
>>
>> Both of those slices have non-zero capacity yet one of them will be
>> the lucky one to grab it. Such semantic issues make me unhappy.
On Monday, 5 June 2017 at 23:17:46 UTC, Ali Çehreli wrote:
auto a = [ 1, 2, 3, 4 ];
auto b = a;
Both of those slices have non-zero capacity yet one of them
will be the lucky one to grab it. Such semantic issues make me
unhappy. :-/
Ali
You have to remember that slices don't own the
On 06/05/2017 03:16 PM, ag0aep6g wrote:
> The spec says [1]: "one may use the .capacity property to determine how
> many elements can be appended to the array without reallocating." So the
> space indicated by `.capacity` is reserved for the array.
Cool. Thanks!
>> 3) Bonus: Shouldn't the array
On 06/05/2017 11:08 PM, Ali Çehreli wrote:
Imagine an array that wants to reuse its buffer after removing elements
from it. For example, a PID waiting list can remove completed elements
and add new ones at the end.
The code would call assumeSafeAppend like this:
arr = arr.remove!(e => e
Imagine an array that wants to reuse its buffer after removing elements
from it. For example, a PID waiting list can remove completed elements
and add new ones at the end.
The code would call assumeSafeAppend like this:
arr = arr.remove!(e => e % 2);
arr.assumeSafeAppend();
1) Assumin