[swift-evolution] [Pitch] making where and , interchangeable in guard conditions.

Joe Groff jgroff at apple.com
Tue May 24 12:31:15 CDT 2016


> On May 24, 2016, at 10:07 AM, Erica Sadun <erica at ericasadun.com> wrote:
> 
> The where clause is not a stylistic flourish because it is still best used to constrain conditions that are semantically
> related to conditions. Upon acceptance as now, there are no compiler checks that mandate any relationship. 

From a semantic perspective, at least, 'where' and ',' don't really matter to the compiler. Either one is an "and" composition of the list conditions.

-Joe

> The difference is that (1) coders will be allowed to move Boolean assertions out of where clauses when there is no
> relationship, and (2) they will be allowed to order the statements as desired. Under the current system, all boolean
> clauses must be conjoined and expressed as the first item of the list (except after availability clauses, as the one exception)
> 
> -- E
> 
>> On May 24, 2016, at 11:01 AM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>> 
>> With the implementation of your proposal, will there be anything that can be written in where clauses that cannot be written after a comma (in the context of guard statements specifically)? If not, does the where clause become entirely a stylistic flourish?
>> On Tue, May 24, 2016 at 11:57 Erica Sadun <erica at ericasadun.com> wrote:
>> There is no way I could figure out how to restrict Boolean assertions to mentioned variables therefore I left where clauses entirely untouched.
>> I'd recommend people adopt in-house standards where Boolean assertions in where clauses should be semantically tied to the condition
>> clause that introduces them.
>> 
>> I will add this as a note.
>> 
>> -- E
>> 
>> 
>>> On May 24, 2016, at 9:29 AM, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
>>> 
>>> Does this proposal distinguish between "where clauses [...] restricted to a Boolean assertion tied to variables connected to the binding or pattern condition" and "unrelated Boolean assertions [that] should be allowed to stand on their own"?
>>> 
>>> Or are both types of boolean assertions now permitted either following a comma or following a where clause?
> 



More information about the swift-evolution mailing list