An optional/maybe type with range semantics

Meta jared771 at gmail.com
Mon Feb 26 15:27:11 UTC 2018


On Monday, 26 February 2018 at 15:21:27 UTC, Dukc wrote:
> Honestly, I fail to see the idea behind this... Ranges do not 
> need any nullability on top of them IMO, because an empty range 
> can already be used to denote a kind of "default", "unassigned" 
> or "nothing" - type of value.
>
> On the other hand I may just be missing something... do you 
> have an example use case for this where phobos ranges would be 
> a bad option?
>
> Anyway, good effort.

The idea is to treat `Option!T` as a regular input range so it 
can be used with all the regular range algorithms without special 
casing it. You're right in that the null/non-null dichotomy is 
equivalent to the notion of a range being empty or non-empty.


More information about the Digitalmars-d-announce mailing list