Shared - Another Thread

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Oct 17 22:56:26 UTC 2018


On Wed, Oct 17, 2018 at 10:13:37PM +0000, Stefan Koch via Digitalmars-d wrote:
> On Wednesday, 17 October 2018 at 21:55:48 UTC, H. S. Teoh wrote:
[...]
> > But nobody will be building a fusion engine out of race conditions
> > anytime in the foreseeable future. :-D
[...]
> Now my analogy sounds silly.

Silly or not, think of the (fictional) possibilities if we *could* build
fusion engines out of race conditions!  We could power starships with a
team of incompetent programmers.  It would revolutionize everything!


> It's still valid though.
> 
> If something might be used by someone else it's better not to touch
> it, unless one has confirmation it is not used by someone else.
> 
> This is what shared has to enforce.

Yes.  But how can the compiler statically verify this?  Because if it
cannot be statically verified, then somewhere along the line we have to
trust the programmer. Ergo, it's programming by convention, and we all
know how effective that is.

But I'm not sure if it's possible for the compiler to verify it, unless
the language itself has a well-defined concurrency model with
well-defined semantics.  Otherwise the best you could do is to implement
heuristics, which will either lead to holes in the type system, or to an
overly-restrictive conservative type system that nobody will use.


T

-- 
An elephant: A mouse built to government specifications. -- Robert Heinlein


More information about the Digitalmars-d mailing list