'goto', as an indicator of good language

Paul Backus snarwin at gmail.com
Fri Sep 9 14:18:04 UTC 2022


On Friday, 9 September 2022 at 14:03:57 UTC, Nick Treleaven wrote:
> I'd prefer to write it as:
> ```d
>     switch
>     {
>         if (FuncDeclaration func = 
> sc.parent.isFuncDeclaration())
>         {
>             tm.symtab = func.localsymtab;
>             if (!tm.symtab) break;
>             // Inside template constraint, symtab is not set 
> yet.
>         }
>         else
>             tm.symtab = sc.parent.isScopeDsymbol().symtab;
>     //L1:
>         assert(tm.symtab);
>         tm.ident = Identifier.generateId(s, tm.symtab.length + 
> 1);
>         tm.symtab.insert(tm);
>     }
> ```
> Where `switch` works like `switch(0) default:` today.

I think maybe a more intuitive keyword for this would be `do`:

```d
do
{
     // ...
     if (whatever) break;
     // ...
}
```

...which would work like `do { ... } while (0);` currently does.


More information about the Digitalmars-d mailing list