Would it make sense to make it so that __gshared implicitly converted to shared? It's my understanding that the main purpose of __gshared is to be able to better interact with C code, but given the issues with shared, lots of people have just used __gshared instead of shared. This causes a problem in some cases. For instance, none of Mutex's functions are currently shared in spite of the fact that it really doesn't make sense to have a Mutex which is thread-local, but it can't have all of its functions be only shared, because then it wouldn't work with __gshared. That means that in order to work with both __gshared and shared, all of its functions must be duplicated, which is obviously less than ideal.
So, given that __gshared is shared across threads like shared is (just with fewer protections), would it make sense to make it so that __gshared implicitly converts to shared? Then a type like Mutex which is intended to be shared, can just make all of its member functions shared, and it'll work with both __gshared and shared. It may also be necessary to make shared implicitly convert to __gshared for that to work cleanly (particularly when you get stuff like a member function returning a reference variable which then must be shared, even if the original variable were __gshared - because the function itself is shared), and I don't know how big a problem that would be. But I think that the basic idea of allowing implicit conversions at least from __gshared to shared (if not shared to __gshared) is worth exploring. Is there a major reason why it would be a bad idea? My experience with both is limited, and I may just be completely missing something here. - Jonathan M Davis
