Why we need scope(success) if I can write at the end?
spir
denis.spir at gmail.com
Fri Jan 21 06:41:05 PST 2011
On 01/21/2011 02:18 PM, tamir wrote:
> or what's the differents between theese two:
> void transactionalCreate(string filename) {
> string tempFilename = filename - ".fragment";
> scope(success) {
> std.file.rename(tempFilename, filename);
> }
> auto f = File(tempFilename, "w");
> }
> and:
> void transactionalCreate(string filename) {
> string tempFilename = filename - ".fragment";
> auto f = File(tempFilename, "w");
> std.file.rename(tempFilename, filename);
> }
I'm a newcomer as well, so take my answer with a good dose of doubt.
There is no difference AFAIK.
scope(success) allows defining end-of-scope process for a given element
--here the file-- in case of success using an idiom consistent with
other possible outcomes (read: exit, failure). I find this a Good Thing,
personly.
Denis
_________________
vita es estrany
spir.wikidot.com
More information about the Digitalmars-d-learn
mailing list