DIP 1003 Formal Review

Basile B. via Digitalmars-d digitalmars-d at puremagic.com
Sun May 14 19:02:42 PDT 2017


On Monday, 15 May 2017 at 01:39:34 UTC, MysticZach wrote:
> Not that a whole new way of doing things is called for... but I 
> think a better design would have been to allow 'in' and 'out' 
> statements in the function itself, with no need for brackets if 
> you only have one line's worth of contract, e.g.,
>
> int fun(int a) {
>   in assert(...);
>   out(x) assert(...);
>
>   // do stuff
> }

It's nice, i like it but it cant work as simply. You're 
forgetting that interface member functions can have contracts. 
With this syntax interfaces member functions would always have a 
body BUT the current semantic is that interface member functions 
with bodies are final methods. Boom. Interfaces don't work 
anymore because there's no easy way to make the difference 
between an interface member function that's final and an 
interface member function that's not pre-implemented (so 
overridable) but has contracts.



More information about the Digitalmars-d mailing list