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

[REBOL] Re: Help function for contracts

From: jan:skibinski:sympatico:ca at: 18-Oct-2002 20:13

Gregg Irwin wrote:
> Also, what do you think about ordering the parameters to CONTRACT in the > order that they are applied (as it were): spec pre local body post ?
I just posted the updated version of dbc.r The blocks have been reordered, as you suggested. I also added a wrapper, which takes a regular existing function and wraps a contract arount it, as in: g: wrap-dbc pre :f post I might extend it a bit to handle native! functions too. Some fiddling was required because a spec copied from a function f, such as: ["Comment" x [integer!]] would get converted by the "make function! spec body" into: ["Comment" x [datatype!]] Apparently what looked and was printed as 'word was not a 'word at all! :-) One question: How to programmatically insert line breaks into a series of blocks? The reason for this is that I'd like to maintain a neat layout of a source code produced by the wrapper. Inside the wrap-dbc you will see an ugly trick with empty blocks that almost does what I want. body: reduce [ [] 'require pre [] to-set-word 'result 'do fun-body [] 'ensure post [] 'result ] Best wishes, Jan