Shortcut evaluation for hierarchy of in contracts
Daniel Murphy
yebblies at nospamgmail.com
Fri Jul 1 10:38:12 PDT 2011
"Timon Gehr" <timon.gehr at gmx.ch> wrote in message
news:iukvrl$1c1c$1 at digitalmars.com...
>
> Sure, if you remember the Foo/Qux example (Foo is parent, Qux is child,
> method
> bar(a,b), parent requires a>0 child requires else b>0)
>
> void main(){
> auto a=new Foo, b=new Qux;
> a.bar(1,-1);//ok
> b.bar(1,-1);//ok, child works everywhere parent works
> //a.bar(-1,1);// not ok
> //b.bar(-1,-1)// not ok
> b.bar(-1,1);//ok, child works too if b>0
> }
And it finally clicks! Thanks for taking the time to explain it to me.
(If only I'd got it sooner, I wouldn't have spent the last two hours
implementing my behaviour in the compiler)
More information about the Digitalmars-d
mailing list