<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>Ok, I see. However this could be a potential source of bugs/performance issues where you don't consider the nil case and you do some unnecessary work. By prohibiting to pass nil you have to manually unwrap and you immediately see the "optionality".</div><div><br>Am 15.08.2016 um 22:36 schrieb Tim Vermeulen <<a href="mailto:tvermeulen@me.com">tvermeulen@me.com</a>>:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div class="">Oh, that’s true, I misunderstood your previous message. It’s not about passing nil, but it’s about passing optionals. The point is to be able to do something like this:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> number = functionThatReturnsAnOptional()</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">sequence(first: </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">number</span><span style="font-variant-ligatures: no-common-ligatures" class="">, next: { $0 % </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span><span style="font-variant-ligatures: no-common-ligatures" class=""> == </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span><span style="font-variant-ligatures: no-common-ligatures" class=""> ? $0 / </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span><span style="font-variant-ligatures: no-common-ligatures" class=""> : </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">nil</span><span style="font-variant-ligatures: no-common-ligatures" class=""> })</span></div></div><br class=""><div><blockquote type="cite" class=""><div class="">On 15 Aug 2016, at 22:26, Maximilian Hünenberger <<a href="mailto:m.huenenberger@me.com" class="">m.huenenberger@me.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Probably I didn't understand your proposal. What do you want to change exactly?<br class=""><br class="">I thought:<br class="">public func sequence<T>(first: T, next: @escaping (T) -> T?) -> UnfoldFirstSequence<T> { ... }<br class=""><br class="">To:<br class="">public func sequence<T>(first: T?, next: @escaping (T) -> T?) -> UnfoldFirstSequence<T> { ... }<br class=""><br class=""><blockquote type="cite" class="">Am 15.08.2016 um 22:17 schrieb Tim Vermeulen <<a href="mailto:tvermeulen@me.com" class="">tvermeulen@me.com</a>>:<br class=""><br class="">You can’t; the `first` parameter has type `T`, not `T?`.<br class=""><br class=""><blockquote type="cite" class="">On 15 Aug 2016, at 22:10, Maximilian Hünenberger <<a href="mailto:m.huenenberger@me.com" class="">m.huenenberger@me.com</a>> wrote:<br class=""><br class="">Hi Tim,<br class=""><br class="">If you pass "nil" to "first" isn't this an empty sequence? So it would be redundant.<br class=""><br class="">Best regards<br class="">Maximilian<br class=""><br class=""><blockquote type="cite" class="">Am 15.08.2016 um 01:27 schrieb Tim Vermeulen via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>>:<br class=""><br class="">sequence(first:next:) takes a non-optional first argument. Is there a reason for that? sequence(state:next:) allows empty sequences, and I don’t see why sequence(first:next:) shouldn’t. The fix would be to simply add the `?` in the function signature; no other changes are required to make it work.<br class=""><br class="">I considered just filing a bug report, but since this is a change of the public API...<br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></blockquote></blockquote><br class=""></blockquote></div></div></blockquote></div><br class=""></div></blockquote></body></html>