DIP 1003 Formal Review

jmh530 via Digitalmars-d digitalmars-d at puremagic.com
Tue May 16 14:39:19 PDT 2017


On Monday, 15 May 2017 at 02:02:42 UTC, Basile B. wrote:
>>
>> 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.

I agree with your points, but it doesn't necessarily preclude 
adding in/out statements. My only qualm is that they would seem 
very similar to scope statements. Perhaps scope(in) and 
scope(out(x)) or something like that. Would not break any code to 
do it.


More information about the Digitalmars-d mailing list