> On Mar 23, 2016, at 8:11 PM, Dany St-Amant via swift-evolution 
> <[email protected]> wrote:
> 
>> A fourth alternative would be to change the syntaxes of `if` and `while` 
>> (and probably `for` and `switch`) to also have a keyword in this position.
>> 
>>      if expr then { code }
>>      while expr do { code }
>>      for elem in expr do { code }
>>      switch expr among { code }
>> 
>> I'm not going to say I advocate for this option, but it *would* clearly mark 
>> the end of the condition so that trailing closures could be brought to all 
>> of these statements, so it seemed worth mentioning.
> 
> Could such new keywords be optional, only required when the compiler see the 
> construct as ambiguous? 

No.  If the compiler could tell when the keyword was necessary, we just 
wouldn’t require it! :-)

The other approach you could take is to only use this sort of keyword when a 
trailing closure is present, but at that point, you might as well just wrap the 
trailing closure with parentheses (which is already supported today, and the 
compiler now nudges you towards).

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

Reply via email to