To escaping autoclosure or to autoclosure escaping

That is the question eating me away these days. (Yes. I do have a very easy life.)

Be that as it may, when I'm confronted with these sort of heavy questions, I always ask myself "How would I write this wrong?".

And then, I do the opposite.

I don't claim @escaping @autoclosure to be superior to @autoclosure @escaping when referring to escaping autoclosures, though.

I'm kidding... I do. I do claim that.

But don't let my pompous, derisive, bordering on insulting adorable sweet-talk persuade you just yet, because when greping .swift files across all of Apple's open-source projects, I get 92 matches for @autoclosure @escaping and a mere 20 for @escaping @autoclosure, and when inquiring 289 open source Swift libraries I find 203 matches for @autoclosure @escaping and meager 8 for @escaping @autoclosure.

:8ball: !

What were these numbers telling me? I contemplated.

A few hours later, I concluded that both Apple and the Swift community at-large seem to have a very strong preference for using these two terms together such that it reads like a an autotranslated closed caption of a "Try! Swift" conference in Japanese. (exhibit a)

To conclude, and in spite of the gross redundancy of almost every word in this post, I do wonder in seriousness. Could it be that my unparalleled genius and raccoon-like instincts missed something? I know for sure the ordering makes no semantic difference... Does it? And if the majority simply doesn't care, why would one default to write bad when the option to write good is available at the same price? Is it possible, and I'm only asking here, is it possible that I'm misplacing my priorities?

Thank you for indulging me into wasting your time, probably.

With the highest esteem, I am a friend of virtue and the people,

1 Like

I think at least part of the propensity of @autoclosure @escaping over @escaping @autoclosure is, in part, due to the fact that before non-escaping was the default there was such a thing as @autoclosure(escaping).

1 Like

Ah yes. I do remember those times. It does still seem silly to me though whenever I see "@autoclosure @escaping" lurking around an stdlib written in a language where literary works such as withContiguousStorageIfAvailable, lexicographicallyPrecedes and withoutActuallyEscaping exist.

1 Like
Terms of Service

Privacy Policy

Cookie Policy