Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

design by contract docs ...

 [1/1] from: m::koopmans2::chello::nl at: 19-Sep-2001 18:00


Yes, it does help you a lot, as you can have pre and post conditions. A contract takes the form: test: contract [param-block] [ pre [ [cond1] [cond2]] post [[cond1][cond2]] ] [ local vars] [body] the pre and post parts are optional, and a condition may contain code in parntheses, so you can have dynamic conditions per contarct invocatation (conditions are composed everytime they are invoked). We use it or our large scale app to do database checks and all sorts of things: - Does a customer exist? - Is the connection alive - is the input a positive number? It realy helps to robustify your code. If a condition is violated you get an error of the form: --the post condition "x>0" was not met You can find contract.r in the Rebol script lib. --Maarten