[swift-evolution] [Pitch] make @noescape the default

Dmitri Gribenko gribozavr at gmail.com
Sat Dec 19 18:38:35 CST 2015


On Sat, Dec 19, 2015 at 12:10 PM, Matthew Johnson via swift-evolution
<swift-evolution at swift.org> wrote:
> @noescape is safer because it does not require thinking about lifetime issues for captured objects.  My hunch was that @noescape (or @autoclosure with implies @noescape) is also more common.  I had a look through the standard library and this is definitely the case there.
>
> What does everyone think about making @noescape the default and introducing @escaping (or something similar) to annotate function arguments that do escape the call stack?

@noescape provides additional guarantees and the optimizer can learn
to rely on it in future.  Thus, it effectively becomes ABI, and you
can't remove in future versions of the library without breaking the
ABI.  I think adding it should be an explicit decision because of
that.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-evolution mailing list