Created
March 14, 2011 19:00
-
-
Save masak/869659 to your computer and use it in GitHub Desktop.
What is this DBC thing and how does it work?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
According to S04:1454... | |
In the normal course of things, C<CALL-VIA-DBC> follows these steps: | |
1. create an empty stack for scheduling postcalls. | |
2. call all the appropriate per-class C<PRE> submethods, | |
pushing any corresponding C<POST> onto the postcall stack. | |
3. call all the appropriate per-method C<PRE> phasers, | |
pushing any corresponding C<POST> onto the postcall stack. | |
4. enforce DBC logic of C<PRE> calls | |
5. call the method call itself, capturing return/unwind status. | |
6. pop and call every C<POST> on the postcall stack. | |
7. enforce DBC logic of C<POST> calls | |
8. continue with the return or unwind. | |
In light of that, what should this code do? | |
class A { | |
method foo($x) { | |
PRE { $x < 10 } | |
say "A.foo called!" | |
} | |
} | |
class B is A { | |
method foo($y) { | |
PRE { $y < 5 } | |
say "B.foo called!" | |
} | |
} | |
B.new.foo(3); | |
class C is A { | |
method foo($z, $w) { | |
PRE { $z < $w } | |
say "C.foo called!" | |
} | |
} | |
C.new.foo(7, 9); | |
What I'm really asking is what "all the appropriate" means in point 3. | |
I'm not sure I see how DBC could work without a tighter enforcing of the | |
more basic Liskov properties than is the case in vanilla Perl 6. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment