Great points Kevin, that's pretty much my thinking as well. If we're
heading towards everything being an expression then it'll happen, perhaps
that change shouldn't be incremental as you've suggested, I'm not sure.

The only time I've found I've naturally wanted to do this is with things
like property definitions:

var twiceSomething: Int { self.something * 2 }



On Sun, Dec 20, 2015 at 1:55 PM, Kevin Ballard via swift-evolution <
[email protected]> wrote:

> If Swift ever changes to be Rust-like and have every statement actually be
> an expression with a non-void type (I believe this was discussed in the
> thread about replacing ?:), then your proposed behavior is already an
> implicit part of that change.
>
> But barring a large change like that, I'm against dropping the `return`
> here, as it's inconsistent with the rest of the language. The only
> construct today that lets you drop the return is a one-line closure, but
> that's already something that looks like an expression (`foo.map({ $0.x })`
> looks perfectly fine; `foo.map({ return $0.x })` is just unnecessary
> syntax). But the last statement of a function isn't an expression, it's a
> statement.
>
> -Kevin Ballard
>
> On Sat, Dec 19, 2015, at 05:30 AM, Craig Cruden via swift-evolution wrote:
>
>
> When writing short functional code in a function it would be nice if the
> return keyword were an optional keyword.
>
> Just return the last evaluated expression.
>
>
> i.e.
>
> func flipFunc<T, U>(arg1: T, arg2: U) -> (U, T) {
>         (arg2, arg1)
>     }
>
>
> The keyword return would still be there for breaking out of a function.
>
> *_______________________________________________*
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
>
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to