An optional/maybe type with range semantics

Dukc ajieskola at gmail.com
Mon Feb 26 16:02:58 UTC 2018


On Monday, 26 February 2018 at 15:27:11 UTC, Meta wrote:
> 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.

I kinda start to see the idea... Granted, nullable is in a way a 
range that can hold exactly one or exactly zero elements. Not a 
bad idea at all.

But shouldn't it store the value internally as a pointer, not as 
an array, to save a bit space? When empty, it would point to null.


More information about the Digitalmars-d-announce mailing list