On Tue, Sep 29, 2020 at 09:56:41AM +, ikod via Digitalmars-d-learn wrote:
> Hello,
>
> Sorry if I unintentionally hurt anybody in this thread.
> I'll try to implement sane and correct iteration behavior for AA
> without noticeable performance loss, and propose it if I succeed.
No feelings
Hello,
Sorry if I unintentionally hurt anybody in this thread.
I'll try to implement sane and correct iteration behavior for AA
without noticeable performance loss, and propose it if I succeed.
Igor
On Sunday, 27 September 2020 at 13:02:04 UTC, Per Nordlöw wrote:
Is it safe to remove AA-elements from an `aa` I'm iterating
over via aa.byKeyValue?
I'm currently doing this:
foreach (ref kv; aa.byKeyValue)
{
if (pred(kv.key))
aa.remove(kv.key); // ok?
}
if
On 9/28/20 1:18 PM, ikod wrote:
On Monday, 28 September 2020 at 14:58:15 UTC, Steven Schveighoffer wrote:
On 9/27/20 4:43 PM, Per Nordlöw wrote:
On Sunday, 27 September 2020 at 14:23:11 UTC, H. S. Teoh wrote:
No. Modifying a container while iterating over it is, in general, a
bad idea
On Mon, Sep 28, 2020 at 08:04:49PM +, ikod via Digitalmars-d-learn wrote:
> On Monday, 28 September 2020 at 19:18:20 UTC, H. S. Teoh wrote:
[...]
> > The problem with arbitrary, unrestricted modification of a container
> > while iterating over it, is that it inevitably leads to
> >
On Monday, 28 September 2020 at 19:18:20 UTC, H. S. Teoh wrote:
On Mon, Sep 28, 2020 at 05:18:41PM +, ikod via
Digitalmars-d-learn wrote:
On Monday, 28 September 2020 at 14:58:15 UTC, Steven
Schveighoffer wrote:
[...]
> One could write a specific function to iterate and remove. I
This
On Mon, Sep 28, 2020 at 05:18:41PM +, ikod via Digitalmars-d-learn wrote:
> On Monday, 28 September 2020 at 14:58:15 UTC, Steven Schveighoffer wrote:
[...]
> > One could write a specific function to iterate and remove. I
>
> This looks like dead end to me, as you may not only remove items
On Monday, 28 September 2020 at 14:58:15 UTC, Steven
Schveighoffer wrote:
On 9/27/20 4:43 PM, Per Nordlöw wrote:
On Sunday, 27 September 2020 at 14:23:11 UTC, H. S. Teoh wrote:
No. Modifying a container while iterating over it is, in
general, a bad idea (unless the container is designed to be
On 9/27/20 4:43 PM, Per Nordlöw wrote:
On Sunday, 27 September 2020 at 14:23:11 UTC, H. S. Teoh wrote:
No. Modifying a container while iterating over it is, in general, a
bad idea (unless the container is designed to be used that way, but
even then, such removal is generally restricted),
On Monday, 28 September 2020 at 10:01:23 UTC, ikod wrote:
Is it specific to some types? What if collection supports
stable "foreach"?
Yes it depends on how collection members (such as insert, find,
replace, erase, etc) are implemented.
I presume we need attributes on mutating collection
On Monday, 28 September 2020 at 10:10:10 UTC, Per Nordlöw wrote:
On Monday, 28 September 2020 at 10:01:23 UTC, ikod wrote:
Is it specific to some types? What if collection supports
stable "foreach"?
Yes it depends on how collection members (such as insert, find,
replace, erase, etc) are
On Monday, 28 September 2020 at 09:41:02 UTC, Per Nordlöw wrote:
On Monday, 28 September 2020 at 07:15:27 UTC, Imperatorn wrote:
Yes, this should be a compile-time error
Spec here:
https://dlang.org/spec/statement.html#foreach_restrictions
Is it specific to some types? What if collection
On Monday, 28 September 2020 at 07:15:27 UTC, Imperatorn wrote:
Yes, this should be a compile-time error
Spec here:
https://dlang.org/spec/statement.html#foreach_restrictions
On Sunday, 27 September 2020 at 20:43:19 UTC, Per Nordlöw wrote:
On Sunday, 27 September 2020 at 14:23:11 UTC, H. S. Teoh wrote:
[...]
I believe it's high time we start thinking about detecting
these violations at compile-time. I recall it's in the spec
somewhere so we should start a
On Sunday, 27 September 2020 at 14:23:11 UTC, H. S. Teoh wrote:
On Sun, Sep 27, 2020 at 01:02:04PM +, Per Nordlöw via
Digitalmars-d-learn wrote:
Is it safe to remove AA-elements from an `aa` I'm iterating
over via aa.byKeyValue?
No. Modifying a container while iterating over it is, in
On Sunday, 27 September 2020 at 14:23:11 UTC, H. S. Teoh wrote:
No. Modifying a container while iterating over it is, in
general, a bad idea (unless the container is designed to be
used that way, but even then, such removal is generally
restricted), because it often leads to highly
On Sun, Sep 27, 2020 at 01:02:04PM +, Per Nordlöw via Digitalmars-d-learn
wrote:
> Is it safe to remove AA-elements from an `aa` I'm iterating over via
> aa.byKeyValue?
No. Modifying a container while iterating over it is, in general, a bad
idea (unless the container is designed to be used
On Sunday, 27 September 2020 at 13:02:04 UTC, Per Nordlöw wrote:
Is it safe to remove AA-elements from an `aa` I'm iterating
over via aa.byKeyValue?
I'm currently doing this:
foreach (ref kv; aa.byKeyValue)
{
if (pred(kv.key))
aa.remove(kv.key); // ok?
}
if
On Sunday, 27 September 2020 at 13:02:04 UTC, Per Nordlöw wrote:
Is it safe to remove AA-elements from an `aa` I'm iterating
over via aa.byKeyValue?
I'm currently doing this:
foreach (ref kv; aa.byKeyValue)
{
if (pred(kv.key))
aa.remove(kv.key); // ok?
}
if
On Sunday, 27 September 2020 at 13:02:04 UTC, Per Nordlöw wrote:
Is it safe to remove AA-elements from an `aa` I'm iterating
over via aa.byKeyValue?
I'm currently doing this:
foreach (ref kv; aa.byKeyValue)
{
if (pred(kv.key))
aa.remove(kv.key); // ok?
}
if
20 matches
Mail list logo