www.digitalmars.com         C & C++   DMDScript  

D - contracts violation (and a request for 'result')

reply "Carlos Santander B." <carlos8294 msn.com> writes:
I think this goes hand with hand with the compile time assert thing.

int foo()
out (result) { assert(result!=0); }
body { return 0; }

Obviously the contract is violated and always will, but it still compiles.
Can't these kind of things be detected at compile time?

The other thing, if we already have 'result' for out contracts, why not also
having them for the entire function body?

-------------------------
Carlos Santander


---

Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.516 / Virus Database: 313 - Release Date: 2003-09-01
Sep 13 2003
parent "Riccardo De Agostini" <riccardo.de.agostini email.it> writes:
"Carlos Santander B." <carlos8294 msn.com> ha scritto nel messaggio
news:bk0e60$2mme$1 digitaldaemon.com...
 The other thing, if we already have 'result' for out contracts, why not
also
 having them for the entire function body?
You have my vote! I'd like "result" to be a keyword meaning a reference to the function's result, so it can be a lvalue. I use this feature in Delphi a lot. Ric
Sep 15 2003