It would be fine if Xcode would mark this as an error if it is not
supported.
Mark what specifically?
But I'd like to hear your explanation :-)
In an ideal world the concurrency context of your code should be subject to static analysis. So, you could look at your code and know what locks it holds just by the context in which it’s compiled. Indeed, that’s exactly what you get when you use Swift concurrency [1].
In lesser environments it’s common to establish a naming convention for this sort of this. For example, function foo()
might take a lock, call function locked_foo()
, and then release the lock. That way the name offers a hint as to whether you expect to be locked or not.
Recursively locks completely undermine that paradigm. The same code will work if it’s called from one context and fail if it’s call from another.
Moreover, recursive locks encourage folks to run large chunks of code under the lock, which is often problematic.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] And enable strict concurrency checking. And we’ve implemented all the features needed to do that reasonably, which is still a bit of a work in progress (-: