DMD 0.148 - scope guard
Lars Ivar Igesund
larsivar at igesund.net
Tue Feb 28 08:36:33 PST 2006
Lucas Goss wrote:
>>> Chris Miller wrote:
>>>>
>>>> scope(exit) foo();
>>>> scope(success) bar();
>>>> scope(failure) baz();
>>>
>
> While I don't really like the _'s in on_scope_exit, etc, I don't like
> this proposed syntax any more, in fact I think I don't like it as much.
> With this proposed syntax it seems like an expression such as an
> if/while/for/etc, however, in all of those the condition is user
> defined. So this proposed syntax would appear inconsistent.
>
> <rant>
> And if there's one thing I dislike in languages and libraries, it's
> inconsistencies, right up with it is non descriptive or inconsistent
> functions. Don't even get me started on those, I'm looking at you Phobos
> :)
>
> writefln ... what? write file name? write first line? write f language?
> isxdigit ... is x a digit? of course not! why do I need this function?
> pardir ... parrot directory? not everyone has the parrot vm.
> altsep ... Alt key seperator? does this get the Alt key?
> ifind ... integer find? iFind? iWork? is this for Mac only?
>
> First, I don't see why all of the above aren't readable. And second, why
> don't they follow the D guidelines of camelCase? (I prefer the
> PascalCase myself, but I could live with camelCase if it was
> consistent). For example:
>
> writeLine(string), writeLine(string, format)
> isHexDigit
> parentDirectory
> windowsAlternateSeperator
> FindFirst
>
> The only reason I can see is "it will make it easier for C/C++
> programmers." or, it's shorter. The first has little merit, as
> templates, operator overloading, streams, reals etc. are all different
> (for good reason of course), and C/C++ programmers will have to learn D
> no matter what. As for shorter, you may gain a few seconds (after a
> couple hundred lines), but I'd much rather be able to tell what I was
> doing at a glance...
>
> (notice: Yes I know, the functions come from C... it's good we hold on
> to our history just like C++ did :) )
> </rant>
>
> I'd much rather prefer something like:
> scopeexit
> scopesuccess
> scopefailure
>
> Or some derivative:
> scopeabort, scopefault, scopedone, scopefinish, scope?
>
> ps. I like the looks of this new feature and find it very elegant. I
> prefer this to try/catch/finally.
Sorry, but I find the proposed statements very consistent with D's existing
version, debug, etc statements.
More information about the Digitalmars-d
mailing list