auto storage class - infer or RAII?

Andrey Khropov andkhropov_nosp at m_mtu-net.ru
Mon Nov 13 06:11:40 PST 2006


JC wrote:

> void drawBox(Rectangle rect, Colour colour) {
>  scope (DrawingContext dc = createDrawingContext()) {
>    scope (Pen pen = new Pen(colour)) {
>      dc.drawRectangle(pen, rect);
>    } // pen is freed here
>  } // dc is freed here
> }
> 
> Used this way, 'scope' as the RAII keyword makes sense.

Heh, that's exactly how 'using' is used in C#.
I prefer usual C++ - like RAII style.

-- 
AKhropov



More information about the Digitalmars-d mailing list