RAII limitations in D?

Timothee Cour via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 21 19:22:05 PDT 2014


What would be a good answer to this article?
http://swiftcoder.wordpress.com/2009/02/18/raii-why-is-it-unique-to-c/

Especially the part mentioning D:{
D’s scope keyword, Python’s with statement and C#’s using declaration all
provide limited RAII, by allowing resources to have a scoped lifetime, but
none of them readily or cleanly support the clever tricks allowed by C++’s
combination of smart pointers and RAII, such as returning handles from
functions, multiple handles in the same scope, or handles held by multiple
clients.
}

This morning I was pointing to some deprecated usage of scope mentioned in
docs (EMAIL:scope classes mentioned in tutorials, but deprecated). The pull
request (https://github.com/D-Programming-Language/dlang.org/pull/637/files)
mentions using struct or classes allocated on the stack via
typecons.scoped. However what about the RAII usage mentioned in the above
article that allows C++ to return handles for eg (impossible via scope),
that get deterministically destroyed?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20140821/4d90b06e/attachment.html>


More information about the Digitalmars-d-learn mailing list