Why not finally allow bracket-less top-level keywords?

FeepingCreature default_357-line at yahoo.de
Sun Mar 18 09:25:21 PDT 2012


On 03/18/12 02:23, Manu wrote:
> The virtual model broken. I've complained about it lots, and people always say "stfu, use 'final:' at the top of your class".
> 
> That sounds tolerable in theory, except there's no 'virtual' keyword to keep the virtual-ness of those 1-2 virtual functions I have... so it's no good (unless I rearrange my class, breaking the logical grouping of stuff in it).
> So I try that, and when I do, it complains: "Error: variable demu.memmap.MemMap.machine final cannot be applied to variable", allegedly a D1 remnant.
> So what do I do? Another workaround? Tag everything as final individually?
> 
> My minimum recommendation: D needs an explicit 'virtual' keyword, and to fix that D1 bug, so putting final: at the top of your class works, and everything from there works as it should.

See subject.

Example;

class Foo : Bar final {
}

as alternative syntax for

class Foo : Bar { final {
} }

Advantages: internally consistent, no need for completely new syntax, "final class" can be deprecated (it never worked well anyway).

Alternate aspects of this syntax change:

void foo(ObjectThing ot, int a, int b) with (ot) {
}

void bar() synchronized {
}


More information about the Digitalmars-d mailing list