Classes or stucts :: Newbie

bearophile bearophileHUGS at lycos.com
Tue Dec 21 00:02:31 PST 2010


It seems I disagree with most things you say in this thread :-)

Jonathan M Davis:

>Talking about SafeD meaning memory safety makes the meaning of safety clear. If you try and make the term safety encompass more than that, it takes very little for "safety" to become subjective. Regardless of whether it would be nice if SafeD gave types of safety other than memory safety, when D documentation and any of the main D devs talk about safety, it is memory safety which is being referred to. Trying to expand the meaning beyond that will just cause confusion regardless of whether the non-memory safety being discussed is desirable or not.<

"SafeD is a misleading name. Names are important because they not just reflect how we see things, but they also shape how we see and how we will see things. If D will want to add "overflow safety" it will need to call those parts "UltraSafeD" :-)

Safety in a language is not so much subjective, just a little. Try to take a look at languages where safety is taken seriously, like SPARK, or even Ada.


>It's trivial to get a reference or pointer to escape and make undetectable to the compiler. Some escape analysis can be and is done, but all it takes is passing a pointer or a reference to another function and the compiler can't determine it anymore unless it has access to the called functions body, and perhaps the bodies of functions that that function calls.<

I think the type system can solve this problem (but where the programmer wants to fool the compiler or punch a hole in the type system on purpose), the not escaping nature of the reference has to become transitive, and the called function too needs the type annotation that ensure that the reference doesn't escape. Probably linear types are one way to do this, but there are more flexible ways to do it (to avoid template bloat this annotation may work as "auto const", so in the binary only one istance of the function will be present even if it is once called with a reference that can't escape and it is called by someone else that gives a free to escape reference).

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list