At 02:18 PM 8/2/00 +1000, Damian Conway wrote:
> > >PS> Perhaps the best of both worlds would be
> > >PS> design-by-contract? A la Conway?
> > >
> > >Conway? Who's Conway?
> >
> > Dunno. He had some sort of thing a few weeks ago. The Public Conway
> 4.0 or
> > something, I think it was. :)
>
>According to the latest TPJ, he's "the Mad Scientist of Perl".
>Clearly a trouble-maker of the worse kind!
The fiend! We shall have to deal with him straightaway. Time to dispatch
the Perl Police! :-P
> > I think I'm missing the point. Why pull 'em out like that? Why not
> > just put the code in the body of the sub?
>
>Same reason that we prefer a while loop to goto: you collect in one place
>all the relevant information that allows you to assess the correctness
>of the subroutine.
>
>An even better reason is that, by decoupling the interface contract from
>the implementation details, you allow the conditions to be inherited by
>methods in a derived class, even (or perhaps *especially*) when the
>implementation is replaced.
Okay, the "Duh!" light just flashed on. I see... nevermind.
>Rest assured that I will be putting in an RFC proposing these and other
>DBC constructs, as part of a suite of proposals for revamping Perl's OO
>mechanisms.
>
>Now, where did I leave that bucket of tuits???
On the plane, in that little seat-back pocket next to the vacuous travel
magazine. Better check with lost & found.
> > Though a good post condition would benefit from some sort of
> > unconditional catch of return, I suppose. Perhaps allowing
> > continue on the outer sub block...
>
>Argh, no! A good postcondition is either invisible to the client code, or
>makes its presence felt only through the effect of turning a bad final
>state (or return value) into an exception. It does *not* offer a last
>chance to monkey with the return value!
continue made sense as a way to tack on post-conditions, if that was all
that was getting tacked on. Since it seems other things are sensible, I
defer to your superior judgement in these things. (Plus I think it'll make
the folks at the office absolutely thrilled)
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk