the List example

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Nov 5 08:06:03 PST 2009


Leandro Lucarella wrote:
> A clear example of this, is not being able to take the address of a local.
> This is too restrictive to be useful, as you pointed in you post about
> having to write static methods because of this. If you can't find
> a workaround for this, I guess safety in D can look a little unrealistic.

Sorry, I forgot to mention one thing. My example of List in the thread 
"An interesting consequence of safety requirements" used struct, but it 
should be mentioned there's a completely safe alternative: just define 
List as a class and there is no safety problem at all. Java, C#, and 
others define lists as classes and it didn't seem to kill them. I agree 
that using a struct in D would be marginally more efficient, but that 
doesn't mean that if I want safety I'm dead in the water. In particular 
it's great that pointers are still usable in SafeD. I'm actually 
surprised that nobody sees how nicely safety fits D, particularly its 
handling of "ref".

Andrei



More information about the Digitalmars-d mailing list