[swift-evolution] [Proposal][Discussion] Deprecate Tuple Shuffles
david at hartbit.com
Mon May 8 00:16:41 CDT 2017
> On 7 May 2017, at 00:21, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
> To which human would it be misleading?
> To the writer? No, because the compiler will warn you right away. By the time you're done with writing the first line, it'll warn you that Int and Double are unused variables. And if you try to use x and y, you get an error.
> To the reader? Only if the writer knowingly wrote this misleading code. In other words, it's a nice puzzle, but no reader will encounter this in real-world code, unless they're being tormented by the writer on purpose.
IMHO, the fact that the compiler warns you does no change the fact that it's a very confusing part of the language. It should not be an excuse for fixing it. Consistency teaches us to expect a type after a colon.
>> On Sat, May 6, 2017 at 16:28 Brent Royal-Gordon <brent at architechies.com> wrote:
>> > On May 5, 2017, at 11:06 PM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>> > The identifier after a colon is *never* a type in any pattern matching, and there's no need of which I'm aware to support type annotations in pattern matching. We put colons after labels, and the current syntax is perfectly consistent here. What is the defect you're trying to cure?
>> The defect underlying this proposal: `let (x: Int, y: Double)` looks like it's declaring `x` and `y` of types `Int` and `Double`, but it's actually declaring `Int` and `Double` and binding them to `x` and `y`. Your code's meaning is perfectly unambiguous to the compiler, of course, but it's misleading to the human.
>> Brent Royal-Gordon
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution