Wednesday, December 06, 2006

Programming By Contract and TypeChecking

Using our recently developed macros, we added programming by contract and typechecking support.

Setting compile=assertions,typechecking in your config.php, you can enable or disable it.

How to use it:

function drawRectangle($canvas, $x0, $y0, $x1, $y1) {
#typecheck $canvas: Canvas#
#check $x0 > $x1#
#check $y0 > $y1#
$canvas->draw(new Rectangle($x0, $y0, $x1, $y1));
}

Disabling the checks, improves performance, but checks are great for developing.
We are already adding checks in the main code.

Labels:

0 Comments:

Post a Comment

<< Home