My Language Feature Requests

Craig Black craigblack2 at cox.net
Sun Dec 23 13:58:51 PST 2007


>> Granted.  There are so many ways to mess things up with pointers.  It's 
>> hard to make a systems language "safe".  I guess my approach would be to 
>> make it "safer".
>
> I don't see that. I mean, if D didn't have arrays, you couldn't ever get 
> an array bounds error; if it didn't have pointers, you would have trouble 
> segfaulting; but those are too useful.
>
> I've manually created objects without using the new operator or the 
> constructor. It's ugly. It's error-prone. Overloading new is safer, when 
> you just want to control how the memory is allocated. (I couldn't avoid it 
> because I didn't want to use a constructor.)

I was not proposing that anyone rely on "manually created objects without 
using the new operator or the constructor".  I was proposing that the 
capability to allocate an object on the malloc heap would be moved to 
structs, so that structs behaved like C++ aggregate types.

However, I realize now that this is no longer necessary, because a run-time 
check that enforces pointer restrictions could be removed in release mode.

> Undefined behavior means there are no checks preventing it, but bad things 
> can happen if you do it, so be careful, and it isn't Walter's fault if it 
> explodes in your face.
>
> The point is, it might be a useful thing, in which case you wouldn't want 
> to disallow it. But either way, checking it is too expensive, so calling 
> it undefined behavior should suffice.

Again the run-time check could be removed in release mode, so no harm done. 




More information about the Digitalmars-d mailing list