[swift-evolution] Revisiting SE-0110
Charlie Monroe
charlie at charliemonroe.net
Wed Jun 14 23:45:50 CDT 2017
> On Jun 15, 2017, at 6:01 AM, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
>
>
>> On Jun 12, 2017, at 10:07 PM, Paul Cantrell <cantrell at pobox.com> wrote:
>>
>> What’s the status of this Chris’s double parens idea below? It garnered some positive responses, but the discussion seems to have fizzled out. Is there something needed to help nudge this along?
>>
>> What’s the likelihood of getting this fixed before Swift 4 goes live, and the great wave of readability regressions hits?
>
> We discussed this in the core team meeting today. Consensus seems to be that a change needs to be made to regain syntactic convenience here. Discussion was leaning towards allowing (at least) the parenthesized form, but more discussion is needed.
>
>
> One (tangential) thing that came up is that tuple element names in tuple *patterns* should probably be deprecated and removed at some point. Without looking, what variables does this declare?:
>
> let (a : Int, b : Float) = foo()
Personally, I use this often as "anonymous structs" (which tuples IMHO are). Often, there is a return type used in 1-2 methods and in such case, I feel that declaring a struct MyMethorReturnStruct is unnecessary and I use tuples with named elements, so that the call site can easily access the information it needs, which is particularly convenient if both tuple member are of the same type:
func parseName() -> (firstName: String, lastName: String)
Instead of deprecating this, would it be possible to make this a syntax for generating a truly anonymous structure? It can internally have a name that mangles together the element *names and types*, so:
let name = (firstName: "John", lastName: "Doe")
type(of: name) == _firstName_String_lastName_String_
Hence you would be able to pass this structure wherever it's declared exactly the same, but:
func passName() -> (name1: String, name2: String) {
return parseName() // see above for declaration
}
will result in error as (firstName: String, lastName: String) cannot be converted to (name1: String, name2: String).
>
> ?
>
> -Chris
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
More information about the swift-evolution
mailing list