[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:02283] Re:

From: Dave Thomas <Dave@...>
Date: 2000-03-31 00:27:57 UTC
List: ruby-talk #2283
mrilu <mrilu@ale.cx> writes:

> Me too! I've thought about usefulness of invariants and method conditions
> and tried to find imagine why they are more usefull than normal
> assertions. I don't know. I guess since they are named a little bit
> differently they could be used as a part of the documentation. And there I
> can see their usefulness easily.

There are a couple of things about DBC that make it both incredibly
useful and also hard to implement:

1. Pre- and post-conditions apply both to a method and to anyone that
   overrides that method. So, for example, Object.to_s might have a
   post condition that the return value must be a String. If we have

     class Fred
      def to_s
       return 3
      end
     end

   This will trigger a failure in Object.to_s's postcondition

2. You must be able in the postcondition to access the values of
   variables as they were on entry to the method. For example

   def addOneTo(aValue)
    aValue += 1
    return aValue   # contrived, I know
    post { return = aValue.orig + 1 }
   end

   The notation here is arbitrary, it's the concept I'm trying to get
   across.

We know how to do (1) from within Ruby (that is by writing just Ruby
code). We haven't worked out how to do (2) yet...


Dave

In This Thread