[swift-evolution] [Pitch/Reality Check] Allow instance members as parameter default values

David Waite david at alkaline-solutions.com
Thu Feb 23 03:48:36 CST 2017


> On Feb 22, 2017, at 5:32 PM, Ben Cohen via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> On Feb 22, 2017, at 10:42 AM, Nate Cook via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> Oops, left out that there's this horrifying way of writing it right now:
>> <snip>
>> Nobody wants that.
>> 
> 
> Oh I don’t think it’s all that bad! It also doesn’t need to be an IUO, since you’re unwrapping it immediately into another variable no matter what.

One big issue is that can cause erroneous usage to propagate:

// want to index to the first character after the paren
str.index(str.index(of: “(“), offsetBy: 1)

before this sort of code would give an error saying that the case where “(“ was not found wasn’t handled, but now it will silently give unexpected behavior.

-DW
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170223/b2aa165c/attachment.html>


More information about the swift-evolution mailing list