[#3986] Re: Principle of least effort -- another Ruby virtue. — Andrew Hunt <andy@...>

> Principle of Least Effort.

14 messages 2000/07/14

[#4043] What are you using Ruby for? — Dave Thomas <Dave@...>

16 messages 2000/07/16

[#4139] Facilitating Ruby self-propagation with the rig-it autopolymorph application. — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/07/20

[ruby-talk:03913] Re: require, ensure, and Design by Contract

From: Dave Thomas <Dave@...>
Date: 2000-07-10 15:02:11 UTC
List: ruby-talk #3913
Aleksi Niemel<aleksi.niemela@cinnober.com> writes:

> > and to be
> > able to perform the wrapping on subclasses when needed. 
> 
> Could you say what's the need here? Why do we have to wrap them?

To enforce contracts on their methods.

> >     def incr(n)
> >       n + 1
> >     end
> >     { post: result == n.old + 1 }
> 
> What if the post is real method and working like my example later?
> Can't we pass the copy of the arguments? (Probably not, because it
> leads to some other weird problems... But even so, I don't follow
> you here.

The expression uses a variable 'n', but we can't tell what 'n' is: we
can guess that it's a parameter, but there is no reflection mechanism
that gives you the names and positions of a parameter, so the wrapper
can't synthesize it.

> I'm not sure we're really implementing full-scale Eiffel-type of DBC
> here. I think I saw someone (maybe Dave) saying it's not entirely
> clear we have need for automatic invariant since we can always do it
> explicitly:

That wasn't me. I'm a lazy sod, so I'd use the minimal typing and most 
automation available ;-)


Regards


Dave

In This Thread