> On Jun 16, 2016, at 12:44 PM, Charlie Monroe via swift-evolution 
> <[email protected]> wrote:
> 
> Sorry, didn't have time to actually submit the proposal, but it at least gave 
> me some time to think it through a few more times.
> 
> After reconsiderations, I suggest the following:
> 
> - deprecation of interpolation of optionals.
> - extending the Optional type by:
>       - var detailedDescription: String - which will return the same value as 
> until now: "nil" for nil and "Optional(value)" for .some(_). This is due to 
> .description and .debugDescription's documentation discouraging direct 
> invocation.
> 
>       - func descriptionWithDefaultValue(_ defaultValue: String = "nil") -> 
> String - which would return either the description of the value, or 
> `defaultValue`.
> 
> So, when the compiler runs into interpolation of an Optional, it issues a 
> warning with a fix-it, that by default calls .descriptionWithDefaultValue() 
> on the optional.

I think that this is overcomplicating the issue.  I’d suggest that someone just 
implement a simple compiler patch (which doesn’t need an evolution proposal):

1. Produce a warning when a string interpolation includes a 
non-redundantly-parenthesized optional, saying that this is probably a bug.
2. Attach two notes (with fixits) to the warning:
2a. a note that adds redundant parens around the parameter, silencing the 
warning.
2b. a note that fixits the issue with a “!” or "?? <#placeholder#>"

I agree that this should be fixed.

-Chris

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to