[swift-evolution] [Accepted with Revision] SE-0099 Restructuring Condition Clauses

Haravikk swift-evolution at haravikk.me
Thu Jun 9 05:40:39 CDT 2016

> On 9 Jun 2016, at 09:47, Brent Royal-Gordon <brent at architechies.com> wrote:
>> Can we get some clarification as to why ‘where’ is being chosen to be retired here? I’m deeply disappointed by that decision as enabling the consistent use of comma as a separator does not preclude the use of where for simple cases that don’t require it. I’m all for having a more usable separator for complex conditionals, but I rarely need it, meanwhile in common, simple conditional bindings and patterns I find the ‘where’ keyword a lot more readable, i.e:
>> 	if let value = foo where foo > 5 { … }
> 	if case .cartesian(let x, let y) where x != y = point { ... }
> 	if let value where value > 5 = foo { ... }

Sorry about the immediate followup, but I just recalled you mentioned multiple conditional binding, which would have brackets, so what about the following:

	if case .cartesian(let x, let y where x != y) = point { … }
	if let (value where value > 5) = foo { … }
	if let (foo, bar where foo > 5) = (maybeFoo, maybeBar) { … }

While it requires brackets for the single conditional binding (you could still drop them with no where clause though) it seems easier to read to me. For consistency this would probably apply to your for loop suggestion like:

	for (eachValue where eachValue > 5) in theValues { … }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160609/732c5e1a/attachment.html>

More information about the swift-evolution mailing list