Range Redesign: Empty Ranges

Jonathan M Davis newsgroup.d at jmdavisprog.com
Wed Mar 6 21:17:37 UTC 2024


On Wednesday, March 6, 2024 1:23:52 PM MST Meta via Digitalmars-d wrote:
> Couldn't we somehow fit RefRange into the
> current range hierarchy somewhere, and provide primitives to make
> it more difficult to shoot yourself in the foot?

RefRange was a huge mistake (and it was my mistake). It's basically trying
to force reference semantics on something that has value semantics, and it
causes problems as a result. I don't think that it can actually be made to
work properly - at least not with forward ranges.

IMHO, we need to be able to rely on the semantics of the basic range
operations, and most of the problems with the current range API come from
when operations are under-specified or outright unspecified - be it because
we're trying to support too much (e.g. both structs and classes for ranges),
or because we just didn't actually think to specify what the behavior should
be. And in some cases, we though of it but too late to actually require it
(e.g. you can't actually rely on $ working with random-access ranges,
because we didn't think to require it up front, and too many random-access
ranges had been written that didn't support it by the time we realized our
mistake).

- Jonathan M Davis





More information about the Digitalmars-d mailing list