On 12/09/10 14:48, bearophile wrote:
Norbert Nemec:

Thank you for your clear explanations of the situation.

With FP/DG, this breaks
down and I believe the best one can do is to implement contracts as
run-time checks in the callee, just as it is done in D.

There is also a mixed strategy: to use run-time checks in the callee for FP/DG, 
and something better for the other situations (FP/DG are present in D2 
programs, but they aren't used everywhere).

Indeed - this would mean a bare, unchecked interface for each function and a wrapper that adds contract checks. If the calling code can verify the contract at compile time, it may call the unchecked version. Otherwise (like with FP/DG), it will call the checked wrapper.

In fact, this could be understood like a kind of type-casting: A function interface includes the contract as part of the type information. If the contract is "casted" away (by assigning the function to a FP that does not include a contract) the the FP points to the run-time checked version of the routine.

This concept may even open the road towards FP/DG that include contract information without getting in the way of lightweight, contract-free FP/DGs as we have them now.

Greetings,
Norbert

Reply via email to