August 11
On Thursday, 5 February 2015 at 14:09:10 UTC, bearophile wrote:
> Tobias Pankrath:
>
>> Works as designed: http://dlang.org/phobos/std_algorithm.html#.remove
>
> Unfortunately it's one of the worst designed functions of Phobos:
> https://issues.dlang.org/show_bug.cgi?id=10959
>
> Bye,
> bearophile

Hit this one today,

Has `removeAt` or `removeAtIndex` be added to the std lib?

BTW, for associative array, `remove()` is in-place; but here for std.algorithm.mutation.remove (*keyword*: mutation), one need to do

```
  array = array.remove(index);  // return a new container

  // v.s.
  aa.remove(key);  // return bool (if it's removed)
```

This in-consistence is really bad.


August 11

On Sunday, 11 August 2024 at 06:04:08 UTC, mw wrote:

>

On Thursday, 5 February 2015 at 14:09:10 UTC, bearophile wrote:

>

Tobias Pankrath:

>

Works as designed: http://dlang.org/phobos/std_algorithm.html#.remove

Unfortunately it's one of the worst designed functions of Phobos:
https://issues.dlang.org/show_bug.cgi?id=10959

Bye,
bearophile

Hit this one today,

Has removeAt or removeAtIndex be added to the std lib?

BTW, for associative array, remove() is in-place; but here for std.algorithm.mutation.remove (keyword: mutation), one need to do

  array = array.remove(index);  // return a new container

  // v.s.
  aa.remove(key);  // return bool (if it's removed)

This in-consistence is really bad.

You may want to create a new thread about this in General. If it's going to get changed, now is the time as they're working on updates to Phobos, but they're not going to see this post.

August 11

On Sunday, 11 August 2024 at 06:04:08 UTC, mw wrote:

>

BTW, for associative array, remove() is in-place; but here for std.algorithm.mutation.remove (keyword: mutation), one need to do

  array = array.remove(index);  // return a new container

  // v.s.
  aa.remove(key);  // return bool (if it's removed)

This in-consistence is really bad.

One of them is part of DRuntime, and the other is a function you can optionally import from Phobos. The fact that they do not work the same way is not necessarily bad—they’re from completely different places and serve completely different purposes.

August 11

On Sunday, 11 August 2024 at 06:04:08 UTC, mw wrote:

>
  array = array.remove(index);  // return a new container

I was looking through Phobos to find what might be an appropriate replacement for remove. I read remove’s documentation, and there it says it removes the element in-place, so I checked the implementation and that seems to be true. It moves everything over and then returns the array with the last element sliced off. So, for removing an element from the start of the array you’d be better off using slicing (because it just changes a pointer rather than doing a huge copy) but otherwise it’s pretty efficient.

August 21

On Sunday, 11 August 2024 at 20:57:15 UTC, IchorDev wrote:

>

On Sunday, 11 August 2024 at 06:04:08 UTC, mw wrote:

>

BTW, for associative array, remove() is in-place; but here for std.algorithm.mutation.remove (keyword: mutation), one need to do

  array = array.remove(index);  // return a new container

  // v.s.
  aa.remove(key);  // return bool (if it's removed)

This in-consistence is really bad.

One of them is part of DRuntime, and the other is a function you can optionally import from Phobos. The fact that they do not work the same way is not necessarily bad—they’re from completely different places and serve completely different purposes.

Naa, inconsistency is a bad design.

August 21

On Wednesday, 21 August 2024 at 08:00:04 UTC, aberba wrote:

>

On Sunday, 11 August 2024 at 20:57:15 UTC, IchorDev wrote:

>

On Sunday, 11 August 2024 at 06:04:08 UTC, mw wrote:

>

BTW, for associative array, remove() is in-place; but here for std.algorithm.mutation.remove (keyword: mutation), one need to do

  array = array.remove(index);  // return a new container

  // v.s.
  aa.remove(key);  // return bool (if it's removed)

This in-consistence is really bad.

One of them is part of DRuntime, and the other is a function you can optionally import from Phobos. The fact that they do not work the same way is not necessarily bad—they’re from completely different places and serve completely different purposes.

Naa, inconsistency is a bad design.

Do hate value types for not being consistent with reference types then? That’s the main difference between the two: slices are values and associative arrays are references.

1 2
Next ›   Last »