[Idea] Add blockreturn keyword


(Kenny Leung) #1

Hi All.

Floating another idea.

I often get “return blind” when looking at a method with blocks inside of it. I don’t know whether a return returns from the method or a block within that method. It would be nice to have a totally different keyword for blocks so I could distinguish the two.

-Kenny


(Brent Royal-Gordon) #2

I often get “return blind” when looking at a method with blocks inside of it. I don’t know whether a return returns from the method or a block within that method. It would be nice to have a totally different keyword for blocks so I could distinguish the two.

Without endorsing the idea, I'll suggest the `leave` keyword for this role.

Of course, this also kind of suggests that we ought to support non-local returns, which I don't think is realistic.

(Hmm. *Could* we support non-local returns from @noescape closures passed to rethrows functions?)

···

--
Brent Royal-Gordon
Architechies


(Jacob Bandes-Storch) #3

Some previous discussion in "Pitch: @autoreleasepool attribute for loops":

http://comments.gmane.org/gmane.comp.lang.swift.evolution/2796

···

On Wed, Feb 17, 2016 at 3:05 PM, Brent Royal-Gordon via swift-evolution < swift-evolution@swift.org> wrote:

> I often get “return blind” when looking at a method with blocks inside
of it. I don’t know whether a return returns from the method or a block
within that method. It would be nice to have a totally different keyword
for blocks so I could distinguish the two.

Without endorsing the idea, I'll suggest the `leave` keyword for this role.

Of course, this also kind of suggests that we ought to support non-local
returns, which I don't think is realistic.

(Hmm. *Could* we support non-local returns from @noescape closures passed
to rethrows functions?)

--
Brent Royal-Gordon
Architechies

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution