From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,9a0ff0bffdf63657 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,4b06f8f15f01a568 X-Google-Attributes: gid103376,public X-Google-Thread: f43e6,9a0ff0bffdf63657 X-Google-Attributes: gidf43e6,public X-Google-Thread: 1108a1,9a0ff0bffdf63657 X-Google-Attributes: gid1108a1,public From: Richard Melvin Subject: Re: Software landmines (loops) Date: 1998/09/02 Message-ID: <9qnQhDAAvZ71EwAx@radm.demon.co.uk>#1/1 X-Deja-AN: 387230914 X-NNTP-Posting-Host: radm.demon.co.uk:194.222.155.111 References: <6sbuod$fra$1@hirame.wwa.com> <6silt4$gb0@flatland.dimensional.com> X-Complaints-To: abuse@demon.net X-Trace: news.demon.co.uk 904764916 nnrp-03:29129 NO-IDENT radm.demon.co.uk:194.222.155.111 Organization: n/a MIME-Version: 1.0 Newsgroups: comp.lang.eiffel,comp.object,comp.software-eng,comp.lang.ada Date: 1998-09-02T00:00:00+00:00 List-Id: In article <6silt4$gb0@flatland.dimensional.com>, Jim Cochrane writes > >It appears that this routine has an implied pre-condition: >l.size() == r.size() > snip.. > >I think, more appropriately, it argues for the "Document routine >pre/post-conditions (as well as use assertions as documentation of >program state, where appropriate)" camp. I hardly think so, given that this was a comparison operator for a stack - a stack, pretty much by definition, is variable-length (perhaps with a fixed maximum length, but that's not relevant). Just throwing in extra preconditions to cover bugs in the implementation is not my interpretation of design-by-contract. Otherwise I can revolutionise the world of fast sort algorithms: void sortInLinearTime(Vector & v) { PRE (v.length() < 2); return; } (assuming PRE is counted as an externally-documented precondition, not an assertion). -- Richard Melvin