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

Maxwell Swadling maxs at apple.com
Fri Dec 4 18:00:23 CST 2015


> On 4 Dec 2015, at 3:37 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> 
> 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.
> 
> Dmitri
> 
> -- 
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

I can not reproduce this behaviour. I'm not sure which version of the compiler had this behaviour.



More information about the swift-evolution mailing list