DMD 1.039 and 2.023 releases

Bill Baxter wbaxter at gmail.com
Thu Jan 8 02:31:56 PST 2009


On Thu, Jan 8, 2009 at 5:36 PM, bearophile <bearophileHUGS at lycos.com> wrote:
> Brad Roberts:
>
>> Restating in the form of a question... When would you _ever_ want {...}
>> to not form a scope?
>
> Recently I have shown a possible syntax for express general unsafeties in D code, for example:
>
> unsafe (bounds, overflow) {
>  ... // here there's no array bound checks, not integral overflow checks
> }
>
> I think this safe(...){...} and unsafe(...){...} don't need to form a scope, like static if.
>
> --------------------------
>
> Bill Baxter:
>
>>I do think it would be nice if there was some kind of alternate non-scope block delimiter syntax in D. When you have static ifs mixed with regular ifs and versions it starts to be pretty difficult to see the flow of things. Something like
> static if (x) ::
>     some stuff
> ::<
>
> Probably I don't understand that syntax.

It just means curly braces. I don't really care what syntax it is,
just something besides { and } for non-scope blocks.

> A more full example may help me understand it. But if I understand it correctly, then I don't like that syntax. The {} add a little of noise, but help you know for sure inside where you are

Do they really help you see where you are in something like this:

void Do_something(T)(int i)
{
   if (i == 0) {
     static if (is(T==A)) {
           A.SomeAlias x;
     }
     else static if(is(T==B)) {
           B.SubType x;
     }
     else {
         T x;
      }
      x = ... whatever
   }
   else {
       int y = x;
   }
}

To me it's hard to see those variable declarations as being anything
other than scoped to the blocks they're in.
So all I'm saying is if we could have some different delimiters for
non-scope blocks then it might be nice, and make it easier to see when
scopes are ending and when they are not.

--bb


More information about the Digitalmars-d-announce mailing list