On Fri, May 28, 2021 at 7:04 AM Christopher Barker firstname.lastname@example.org wrote:
My concern about thread safety is about how easy it would be to make it thread unsafe accidentally.
Sure, global is not thread safe, but it is well known that use of global is, to newbies, “bad”, and to more experienced programmers, “to be used with caution, understanding the risks”.
But particularly if static provides a performance boost, people will be very tempted to use it without considering the implications.
If people want a high performance local constant— that sounds something like the constant proposal the OP brought up earlier.
Variable statics are no less thread safe than globals are (nor any more thread safe). They behave virtually identically.
Constant statics are completely thread safe. If you're doing it just for the performance improvement, there's no way that threading can possibly affect it.