Andrei Alexandrescu wrote: > Rainer Deyke wrote: >> You need some syntactic way to distinguish the contained value from the >> container. Using "alias this" seems messy here. Optional!Optional!T is >> both valid and likely to occur. > > Interesting. I wonder whether it's better to fold Optional!(Optional!T) > into Optional!T.
That would be semantically incorrect. Optional!T must be able to hold all possible values of T, plus a distinct null value. Consider: Optional!int upper_limit; Optional!(Optional!int) config_limit = config_file.get("upper_limit"); if (isNull(config_limit)) { upper_limit = default_upper_limit; } else { upper_limit = config_limit; // Could be null. } Then consider that this could be in a template function, with Optional!int supplied as a template argument. -- Rainer Deyke - rain...@eldwood.com