[swift-evolution] Idea: change "@noreturn func f()" to "func f() noreturn"

Radosław Pietruszewski radexpl at gmail.com
Thu Feb 25 16:43:04 CST 2016


> On 25 Feb 2016, at 23:40, Joe Groff <jgroff at apple.com> wrote:
> 
> 
>> On Feb 25, 2016, at 2:40 PM, Radosław Pietruszewski <radexpl at gmail.com> wrote:
>> 
>> Ah, that’s a neat idea! Not sure it’s an improvement though to have a magic type that changes how the compiler treats your method, rather than a rather explicit *attribute* on the method…
> 
> There's no magic. If you can't construct a value of your return type, you can't return.
> 
> -Joe


The magic is somewhere else. Calling a @noreturn function allows you to do things you can’t otherwise do:

func foo() -> Int {
	fatalError()
}


More information about the swift-evolution mailing list