Safety, undefined behavior, @safe, @trusted

Steven Schveighoffer schveiguy at yahoo.com
Thu Nov 5 13:39:48 PST 2009


On Thu, 05 Nov 2009 16:30:42 -0500, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

>>  Most of the usages are like this:
>>  ubyte[1024] buffer;
>> functionThatNeedsBufferSpace(buffer);
>>  where functionThatNeedsBufferSpace takes a ubyte[], thereby taking an  
>> address of the local data.
>>  So it's not explicit address taking, but it's the same thing under the  
>> hood.  There always exists the potential for the stack reference to  
>> escape.
>
> I see, thank you. I am confident that a trusted reap could be  
> implemented in the standard library. (google reap)

I did.  Couldn't find anything.

>> Similar case is scope classes (which are sometimes used to allocate a  
>> temporary class for performance in tango).  I can't see scope classes  
>> being allowed if you can't take addresses of local variables.
>
> Yah, in fact I think scope classes should just go. But don't hold that  
> against me. :o)

They are great when you need temporary objects to do things like filters.   
It works well in Tango's i/o subsystem where everything uses interfaces.

I think they have their place, as long as structs don't implement  
interfaces and the interface concept isn't removed from D.

-Steve



More information about the Digitalmars-d mailing list