Should scope(exit) be valid outside of a scope?

Simen kjaeraas simen.kjaras at gmail.com
Wed May 12 05:36:23 PDT 2010


S <S at s.com> wrote:

> On 2010-05-11 17:58:29 -0700, Jesse Phillips said:
>
>> Don wrote:
>>
>>> If the scope(exit) isn't in a compound statement (ie, if it isn't  
>>> inside
>>> {}), the 'scope' applies only to the statement itself, so that's
>>  ...
>>
>>> Can we just make it illegal?
>>  I don't see a reason to allow it. I vote error.
>
> It is inside a scope.   Not scope(exit)'s fault that you have only it  
> inside your particular scope (the scope of the if statement).   It could  
> produce a warning....

"Warnings are not a defined part of the D Programming Language."[1]

Scope(whatever) as the only piece of code inside a scope is as useless
as wings on an elephant. There might be cases, however, where generated
code would create just that, and thus mayhap it should be just a warning.
Or, one could make it an error if 'staches[2] are omitted. In this
case, generated code should have no problems, and it serves to highlight
that even without 'staches, if introduces a scope.

[1]: http://www.digitalmars.com/d/2.0/warnings.html
[2]: Also known as curly brackets - '{' and '}'
-- 
Simen


More information about the Digitalmars-d mailing list