"private:" remains in effect after end of containing attribute{}
janderson
askme at me.com
Sat Apr 7 16:08:09 PDT 2007
Bill Baxter wrote:
> Daniel Keep wrote:
>>
>> I believe this is because it *should* say: "affects all declarations
>> until the end of the scope", and "final { ... }" doesn't introduce a
>> scope.
>
> These non-scope curly braces have always made me uneasy. Makes it
> difficult for my C++-adjusted eyes to tell at a glance what's still
> active and what's not. I guess C++ has the "namespace {}" non-scope
> block, but that's only used at the top level scope so use cases can't
> get too complicated.
>
> As for an alternative, I guess you could play around with alternate
> block delimiters for non-scope blocks
>
> static if (is(foo==bar)) <<
> writefln("hello world")
> >>
>
> static if (is(foo==bar)) :{
> writefln("hello world")
> }:
>
> static if (is(foo==bar)) |{
> writefln("hello world")
> }|
>
> static if (is(foo==bar)) ::
> writefln("hello world")
> ::
>
> I kind of like ':{ }:' The colons are like a dotted line, a 1-D sieve
> if you will, indicating that things can 'pass through' this block. Also
> meshes well with the non-scoping tags like "private:"
>
> You could phase it in with three-step plan:
> 1) add :{ }: (or whatever) as an alternate syntax which can be used for
> "non-scope block" in the current non-scope contexts (static if, version,
> public etc)
>
> 2) deprecate/warn about uses of plain {} with non-scope blocks.
>
> 3) make plain {} with non-scope blocks an error.
>
> 4) Finally, reintroduce the ability to use {} with things like static
> if, but this time have them really create a scope (where a scope makes
> sense). This way we can ultimately get back to the shiny happy rule of
> '{ }' always makes a scope whenever it can.
>
> On the other hand, no one else seems to be bothered by this but me. I
> thought I'd get this off my chest anyway. :-)
>
> --bb
This is a good idea. I've been bothered by the non-bracketable static
ifs as well. I think the smilely faces are the easiest to read.
-Joel
More information about the Digitalmars-d
mailing list