interfaces and contracts - new pattern

Meta jared771 at gmail.com
Tue Dec 3 17:17:15 UTC 2019


On Tuesday, 3 December 2019 at 17:10:04 UTC, Meta wrote:
> On Monday, 2 December 2019 at 20:30:49 UTC, Adam D. Ruppe wrote:
>> In short use `in(false)` when you `override` a function to 
>> inherit the contract, unless you explicitly want to expand the 
>> input - which you shouldn't do when implementing an interface!
>>
>> Wrote about it in more details here:
>>
>> http://dpldocs.info/this-week-in-d/Blog.Posted_2019_12_02.html
>>
>> i think this is a pretty cool little discovery, thanks too for 
>> the folks on irc for chatting it through.
>>
>> destroy if i missed anything lol
>
> I thought this was a defect that was fixed a long time ago, 
> where if the overriding function has no contract, it is 
> implicitly given a "in (true)" contract, causing the contract 
> of the overridden function to not be run. Am I mistaken as to 
> what the defect was, or as to whether it was fixed, or both?

I think this is the defect in question:
https://issues.dlang.org/show_bug.cgi?id=6856

I see a PR in comment 35: https://github.com/dlang/dmd/pull/4200

But it was closed. However, Iain Buclaw created a successor to 
4200:
https://github.com/dlang/dmd/pull/7510

Which is still open, but Iain ran into stack corruption issues 
when compiling with the -m64 flag... and no further progress. So 
I guess it's just a matter of the bug not being fixed.


More information about the Digitalmars-d-announce mailing list