Safety, undefined behavior, @safe, @trusted

Yigal Chripun yigal100 at gmail.com
Thu Nov 5 23:36:24 PST 2009


On 05/11/2009 23:45, grauzone wrote:
> Ary Borenszweig wrote:
>> grauzone wrote:
>>> Frank Benoit wrote:
>>>> safe should be the default. The unsafe part should take the extra
>>>> typing, not the other way. Make the user prefer the safe way.
>>>
>>> No. D is not C#.
>>
>> D is an unsafe language.
>> C# is a safe language.
>>
>> Like that? :)
>
> If you mean memory safety, then yes and will probably forever be for all
> practical uses (unless D gets implemented on a Java or .net like VM).

C# does allow memory unsafe code inside unsafe blocks. There's an alloca 
and malloca functions for allocating on the stack.

VM is just an abstract (virtual) instruction set. You can design a safe 
native one or an unsafe virtual one. it's all a matter of design 
choices. there's nothing magical about a VM that makes it inherently safe.

IMO D should be safe by default and allow unsafe code when it is 
appropriately marked as such, regardless of a VM.

BTW, so called native code on Intel processors runs in a VM as well.
Intel's cisc instruction set is translated to a risc like micro-ops and 
those micro-ops are executed. the only difference is that this is done 
in hardware by the processor.




More information about the Digitalmars-d mailing list