I like this idea, but unfortunately, void* is read/writeable -- most low-level C functions that use a buffer take void *.

I also think void[] is writeable, and can be created from a void * without a cast.

-Steve


From: Michel Fortin <michel.fortin@michelf.com>
To: Discuss the dmd beta releases for D <dmd-beta@puremagic.com>
Sent: Wednesday, April 11, 2012 8:50 AM
Subject: Re: [dmd-beta] rvalue references

Le 2012-04-10 à 23:36, Jason House a écrit :

> While I have no plans to use it, what mechanism, if any, will allow escaping the address? Usually, casts are the back door, but I don't believe that works in this case.

There's always this middle ground: taking the address of a ref could give you a void*. That way you really can't do anything unsafe with it without a cast.

Heck, with this trick you could even allow SafeD to take the address of anything. You wouldn't be able to do much without a cast beside comparing and printing addresses, but even that could be handy for debugging and checking for aliasing.

--
Michel Fortin
michel.fortin@michelf.com
http://michelf.com/



_______________________________________________
dmd-beta mailing list
dmd-beta@puremagic.com
http://lists.puremagic.com/mailman/listinfo/dmd-beta