Optional and orElse: design feedback/critique?

Alexandru Ermicioi alexandru.ermicioi at gmail.com
Sat Jul 27 14:46:55 UTC 2019


On Saturday, 27 July 2019 at 13:17:32 UTC, aliak wrote:
> Hi,
>
> Can I ask for feedback on what people expect an optional/maybe 
> type to have, and how to behave. There have been a number of 
> discussions on the forums about it so far, and attempted PRs in 
> phobos.

Would be nice to have functionality similar to Optional from java 
8+, such as orElseThrow, orElseGet, ifPresent etc. Also would be 
nice if it worked perfectly with immutable/const data, and when 
Optional itself is immutable/const. Another nice feature would be 
conversion from immutable to const optional, and from 
immutable/const optional to mutable Optional with const payload 
through probably copy constructor and opCast methods.

Best regards,
Alexandru


More information about the Digitalmars-d mailing list