Hash Tables in D

Marc Schütz via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu Jan 7 05:57:19 PST 2016


On Thursday, 7 January 2016 at 12:26:29 UTC, Adrian Matoga wrote:
> b) explicitly disallow removing during iteration, and always 
> throw an Error whenever it is attempted. In some cases it could 
> even be detectable in compile time.
>
> And I don't mean including a single sentence about this 
> somewhere in the docs. I mean an error reported by the compiler 
> and/or runtime. The runtime checks could be disabled for 
> -release, but there should be at least an option to detect such 
> errors.

We don't have the means to do that currently, neither at 
compile-time, nor at runtime. Both would require some kind of 
borrowing detection, either to make the AA `const` during 
iteration, or to set and reset a flag indicating that it's being 
iterated, allowing it to assert() at runtime.

> Probably the worst part of it is that you're free to wrap it in 
> @safe, while it's not safe at all.

That's something we can change right now. I guess `remove` must 
be `@system`.


More information about the Digitalmars-d-announce mailing list