From: adamon@... (Damon) Date: 2002-12-01T19:42:17+09:00 Subject: Re: Design by Contract IIRC, the dbc module below works by opening up the Ruby source file and scanning the the pre/post/inv assertions. It works, but with a little language support the process can be much improved. The Seattle Ruby Brigade has been conducting a langauge audit. comparing Ruby features with those of other languages. Here is a list of features that Python offers but Ruby does not: -------------------------------------------------------------- http://www.zenspider.com/Languages/Ruby/Audit.html Python Syntax/Semantics The following would require changes to the language/interpreter: * Real traceback objects. * Much better object and runtime reflection: --- Code Objects (name, argcount, nlocals, varnames, code, consts, names, filename, firstlineno, stacksize, flags --- Frame Objects (back, code, locals, globals, builtins, restricted, lineno, lasti, trace, exc_type, exc_value, exc_traceback) ---Traceback Objects (next, frame, line, listi) * Doc strings available at runtime * keyword arguments (**keys) * selective import (include in ruby) -------------------------------------------------------------- The second set of itmes (better object and runtime reflection) includes Code Objects replete with name, argcount, firstlineno, etc, which if added to Ruby would facilitate Design by Contract, in addition to a host of meta-programming issues. If Ruby were to adopt these features, Design by Conduct could be re-wrtitten to take advantage of built-in language-support facilities rather than scanning text to locate the pre-conditions, post-conditions and invairants within a method. Any thoughts? --- J J wrote: > Any interest/thoughts on implementing simple design > by contract in Ruby? > Maybe adding Kernel.assert at least? I've written my > own assert, but think > it might make a good addition to the language. > You might want to check out Andy Hunt's implementation: http://www.pragmaticprogrammer.com/ruby/downloads/dbc.html Chad > > >