
G'day. Andrei Alexandrescu <andrei <at> metalanguage.com> writes:
I'm defining an "optional" type for D's standard library modeled similarly to Boost.optional. An interesting question came up - should optional<optional<T>> fold itself into optional<T>, or is "double optional" an interesting concept of its own?
Automatically folding optional<optional<T>> doesn't make any more sense than automatically folding vector<vector<T>>. The reason is very simple: It's reasonable for templated code to use optional<T> (where T is a template argument) for its own internal purposes. This code should not misbehave just because a client wants that template argument to be optional<U>. Don't break parametricity without an extremely good reason. Andrew Bromage