Implementation of DBC
Edit Page
Report
Scan day: 16 February 2014 UTC
64
Virus safety - good
Description: Document and source code on implementation of DBC for CLOS.
;;; dbc.lisp ;;; Design by Contract in Common Lisp. ;;; ================================= ;;; One of the outstanding features of the Eiffel language is that it ;;; supports a concept called Design by Contract. A comprehensive ;;; description is given in the following books ;;; ;;; Object Oriented Software Construction, 2nd ed. ;;; Bertrand Meyer ;;; Prentice Hall PTR, 1997 ;;; ISBN 0-13-629155-4 ;;; ;;; Eiffel: The Language, 2nd ed. ;;; Bertrand Meyer ;;; Prentice Hall PTR, 1992 ;;; ISBN ??? ;;; ;;; but the key point of DBC is that the relationship between a class ;;; and its clients is specified by a contract: There are certain ;;; conditions that the caller of a method specialized on a class has ;;; to fulfill so that the method can do its job (the preconditions) ;;; and the method guarantees certain things after its completion (the ;;; postconditions). Furthermore a class may have certain properties ;;; that are always true about that class; these properties are called ;;; invariants. ;;; ;;; This file contains an implementation of DBC for CLOS. Pre- and ;;; postconditions as well as invariants are specified by qualified ;;; methods of type dbc; the usual before, after and around method ;;; combinations are available for these methods as well. ;;; ;;; Example: ;;; ======= ;;; ;;; (defpackage "DBC-TEST" ;;; (:use "DBC" "CL") ;;; (:shadowing-import-from "DBC" ;;; "DEFCLASS" "MAKE-INSTANCE" "DBC")) ;;; ;;; (in-package "DBC-TEST") ;;; ;;; (defclass test () ;;; ((slot1 :accessor slot1 :initarg :slot1 :initform 0)) ;;; (:invariant (lambda (class) ;;; (format t "~& >> Invariant check for class ~A~%" ;;; class) ;;; ( numberp (slot-value class 'slot1))))) ;;; ;;; (defgeneric test-dbc (arg1 arg2) (:method-combination ;;; dbc ;;; :invariant-check nil)) ;;; (defmethod test-dbc :precondition "first arg zero" ((m test) (n test)) ;;; (format t "~& >> precondition (test test
Size: 2048 chars
Contact Information
Email: —
Phone&Fax: —
Address: —
Extended: —
WEBSITE Info
Page title: | |
Keywords: | |
Description: | |
IP-address: | 193.149.48.8 |
WHOIS Info
NS | |
WHOIS | Status: connect |
Date | Changed: 2007-12-30T20:47:15+01:00 Changed: 2001-12-17T15:37:02+01:00 Changed: 2004-01-22T11:43:35+01:00 |