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

Jacob Bandes-Storch jtbandes at gmail.com
Thu Jan 28 12:08:06 CST 2016


   if bind foo {
       // foo is non-optional in here
   }

   somethingAsync { [weak self] in
       guard bind self else { return }
       // ...
   }

Elegant when you want to rebind the same name!

Jacob

On Thu, Jan 28, 2016 at 10:05 AM, Erica Sadun via swift-evolution <
swift-evolution at swift.org> wrote:

> Do you realize how much confusion it would save if Swift just went with
>
> if bind foo = bar {...}
>
> with let semantics?
>
> -- Erica
>
> > On Jan 28, 2016, at 11:03 AM, Joe Groff via swift-evolution <
> swift-evolution at swift.org> wrote:
> >
> >
> >> On Jan 28, 2016, at 12:43 AM, Brent Royal-Gordon <
> brent at architechies.com> wrote:
> >>
> >>> We have a lot of evidence that 'if var' confuses peopleā€”a lot of users
> think that 'if var' and 'var' bindings in case patterns will write back to
> the original value when this isn't the case.
> >>
> >> Can we address this with a diagnostic?
> >>
> >>      var bar: Int? = 1
> >>      if var foo = bar {
> >>              foo += 1        // Warning: Value is never used after
> modification (foo is a copy, not an alias)
> >>      }
> >>      print(bar)
> >
> > Good idea.
> >
> > -Joe
> > _______________________________________________
> > swift-evolution mailing list
> > swift-evolution at swift.org
> > https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160128/5ee5e272/attachment.html>


More information about the swift-evolution mailing list