[Proposal] Replace thin arrows (->) with fat arrows (=>)


(David Fekke) #1

In wanted to propose either adding the fat arrow (=>), or replacing the
thin arrow with the fat arrow.

I know that Java uses the thin arrow, but JavaScript, TypeScript and C#
both allow the use of the fat arrow for lambda syntax.

Thoughts?

Thanks,
David Fekke


(John McCall) #2

In wanted to propose either adding the fat arrow (=>), or replacing the thin arrow with the fat arrow.

I know that Java uses the thin arrow, but JavaScript, TypeScript and C# both allow the use of the fat arrow for lambda syntax.

Thoughts?

Why?

John.

···

On Dec 18, 2015, at 9:35 AM, David Fekke via swift-evolution <swift-evolution@swift.org> wrote:

Thanks,
David Fekke
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Etan Kissling) #3

The thin arrow in Swift is used to define to result type of a function / closure.

someFuncWithClosure { (a: Int, b: Int) -> String in "\($0 + $1)" }

Am I understanding this correctly that

your first suggestion is

someFuncWithClosure { (a: Int, b: Int) -> String => "\($0 + $1)" }

and your second suggestion is

someFuncWithClosure { (a: Int, b: Int) => String in "\($0 + $1)" }

?

C# doesn't allow specifying the return type for closures (you have to define a delegate type first)

someFuncWithClosure((int a, int b) => string.Format("{0}", a + b));

Etan

···

On 18 Dec 2015, at 18:35, David Fekke via swift-evolution <swift-evolution@swift.org<mailto:swift-evolution@swift.org>> wrote:

In wanted to propose either adding the fat arrow (=>), or replacing the thin arrow with the fat arrow.

I know that Java uses the thin arrow, but JavaScript, TypeScript and C# both allow the use of the fat arrow for lambda syntax.

Thoughts?

Thanks,
David Fekke
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org<mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution


(Radek Pietruszewski) #4

I think you’re confusing (or not being clear about) two things: type declarations and closures. `->` means “a function type returning…” in Swift. I believe what you talk about with fat arrows is a syntax for defining closures.

… and do we need a second syntax for closures in Swift?

No.

— Radek

···

On 18 Dec 2015, at 18:35, David Fekke via swift-evolution <swift-evolution@swift.org> wrote:

In wanted to propose either adding the fat arrow (=>), or replacing the thin arrow with the fat arrow.

I know that Java uses the thin arrow, but JavaScript, TypeScript and C# both allow the use of the fat arrow for lambda syntax.

Thoughts?

Thanks,
David Fekke
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution