[swift-evolution] Reconsidering the (Element -> T?) variant of SequenceType.flatMap

Dmitri Gribenko gribozavr at gmail.com
Fri Dec 4 17:37:47 CST 2015

On Fri, Dec 4, 2015 at 3:34 PM, Kevin Ballard <kevin at sb.org> wrote:
> Personally, I'd be in favor of making Optional conform to SequenceType. I've filed a radar on it before, and I seem to recall a message (probably to this list) yesterday suggesting the exact same thing.

This would be an interesting direction, but we have discussed it a
long time ago, and found an issue in the way it would interact with
implicit promotions to optionals.  Basically, in a call to a function
accepting a Sequence, one would be able to write any non-sequence,
non-optional value, that would be implicitly promoted to optional, and
thus eligible to be passed as a Sequence.  This is the only argument
for not adding this conformance that I know of, but it is a show
stopper unfortunately.


(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/

More information about the swift-evolution mailing list