Andy wrote:
> I wrote a DBC implementation a few weeks ago, but was waiting until

Great! Looks really awesome.

Few questions:

>   def alpha(x)
>     post { DBC.result * 2 == x }

Is there any concurrency issues with DBC.result?

> The invariant should be the last method defined in a class.

Indicating that something "ugly" is being done when invariant is defined.
Maybe that's all right but does it break down when methods are added later
on.

  class Basic
    def foo
    end
    def invariant      # the DBC magic takes place?
    end
  end

  class Basic
    def bar            # adding a method
    end
    # def invariant    # do we need redefinition of invariant here
    end
  end

How about singleton objects with added functionality?

>   check "Descriptive string" { code block }

Where does this write the output? To DBC.check_output_stream, which points
to $stderr by default?

> Once an exception has been raised from an object, that object should
> not be considered viable any more.  In particular, it may not detect

Nice. Promotes not-too-general-exception-catching, so one shouldn't write

  begin
    code_with_DBC
  rescue
  end

anymore.

> By default, DBC is enabled with full checking.  To change the checks

Again nice. But is there a way for partioning checks? Like that this part of
the code uses DBC enabled like this, and that other part doesn't use at all
for performance reasons (even while it's built with DBC).

Any chance to get different versions of DBCs (it seems everyone is doing
their own these days :) to different parts of the code? If you could
associate a DBC manager for the block of code then the rest of the world
wouldn't get bothered you check controlling policy. Nor would other part of
the same library which could use different DBC manager. (Or is it
controller?)

> which are performed, call DBC.enable with one or more of the
> following flags or-ed together:

Just a joke, but couldn't help. When we want to say enable invariant and
post-condition checking we actually say DBC.enable(DBC::INV | DBC::PRE) :).

> dbc.rb must be able to find and parse the source code, so you

Maybe there could be ways to provide the source even when evalling (for
piping I don't know).

> Your program may run a bit slower with all the extra checking.  In

Do you have any idea what's the cost? I guess that your way is quite
streamlined as you probably just include that extra code which have to be
there, so there're no runtime checks for what we should check *each* time
there's a method call.

	- Aleksi