Range Redesign: Copy Semantics

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon Jan 22 02:33:09 UTC 2024


On Sunday, January 21, 2024 7:17:35 PM MST Richard (Rikki) Andrew Cattermole 
via Digitalmars-d wrote:
> On 22/01/2024 3:08 PM, Jonathan M Davis wrote:
> > On Sunday, January 21, 2024 10:39:41 AM MST Richard (Rikki) Andrew
> > Cattermole>
> > via Digitalmars-d wrote:
> >> On 21/01/2024 11:58 PM, Jonathan M Davis wrote:
> >>> Either way, if we're doing a new major version of Phobos, we'll be
> >>> reworking a variety of stuff anyway, and so Nullable would presumably be
> >>> on the list (e.g. I think that it was a big mistake to make it a range,
> >>> and I'd remove that functionality; slicing it to get a range is one
> >>> thing, but the fact that it itself is a range definitely causes problems
> >>> in generic code).
> >>
> >> Umm, why would we bring back Nullable?
> >>
> >> By then we'd have sum types which can represent it in the language far
> >> better.
> >
> > Much as I know that you like the idea of sum types, AFAIK, it's never been
> > officially agreed that we're going to have them in the language, and even
> > if we do get them, I don't know what that's actually going to look like.
> Given that Walter has put together a DIP for them, I'm fairly confident
> it is a question of when not if.
>
> https://github.com/WalterBright/DIPs/blob/sumtypes/DIPs/1NNN-(wgb).md

Well, we'll see what we actually end up with, but I'd consider that proposal
to be terrible if all you want is a nullable type, and restrictions such as
"Members of sumtypes cannot have copy constructors, postblits, or
destructors" would be far too much for plenty of use cases such that I would
still be very much inclined to have an explicit Nullable type.

In any case, whether Phobos v3 has a Nullable type and the question of the
exact type returned by next in the proposed API don't really matter that
much right now. What matters is the basics of the API, and some of the
details can be ironed out later. IMHO, having next return a type that
emulates a pointer is the best choice (especially when we don't even have
sum types yet), but that can be revisited down the line, particularly since
it's not like we're releasing major changes to ranges right now.

- Jonathan M Davis





More information about the Digitalmars-d mailing list