[swift-evolution] Reconsidering SE-0003 Removing var from Function Parameters and Pattern Matching

Charles Constant charles at charlesism.com
Fri Jan 29 06:53:34 CST 2016

Im for keeping this

> if var x = x {

Actually, I'm hoping Swift allows us to group let/var/optional and
non-optional together. At the moment, a lot of my functions start out with
a couple groups of declarations, before I get to the "meat" of my function.
I'm hoping someday  we can do this:

// set up, make sure we unwrap whatever needs unwrapping, and set up
whatever vars we'll use

result_var = Gronk.init()
foo_const = arg.bar_opt,
baz_var = do_something( )
quux_const = 1567
else { return nil }

// the "meat" of my function


The reason I'd like to arrange things this way is that I could spend more
time focusing on the logic side of my functions, instead of having to parse
though where my nil checks, and declarations end.

This might be obvious bad form to someone who's taken more CompSci classes
than I have. I realize that for example, having one point of failure for
several unrelated things is ambiguous, and that there would need to be more
syntax to specify what is being declared as let vs var.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160129/1e0f042b/attachment.html>

More information about the swift-evolution mailing list