Path: utzoo!attcan!uunet!mcvax!ukc!etive!lfcs!dts From: dts@lfcs.ed.ac.uk (Don Sannella) Newsgroups: comp.lang.misc Subject: Re: reusable design vs. reusable code Message-ID: <1167@etive.ed.ac.uk> Date: 20 Dec 88 16:31:17 GMT References: <5200036@m.cs.uiuc.edu> Sender: news@etive.ed.ac.uk Reply-To: dts@lfcs.ed.ac.uk (Don Sannella) Organization: Laboratory for the Foundations of Computer Science, Edinburgh U Lines: 45 Have a look at the modularization facilities in the Standard ML programming language. These allow large programs to be structured into modules with explicitly-specified interfaces. Interfaces (called signatures) and their implementations (called structures) are defined separately. Every structure has an signature, but a given signature can describe lots of different structures. Structures may be built on top of existing structures in a hierarchical way, and the signature reflects this. It is possible to define parameterized structures, called functors. A functor is like a function on the level of structures. Each functor has an input signature describing structures to which it may be applied, and an output signature describing the result of an application. For more information, see the references below. These are just what you want for reusability. I can't explain this adequately in a few lines though -- you have to look at some examples. Functors are generic program components, and the explicit interfaces take care of putting programs together from these components. You can alter implementations as you like; provided the new implementation fits the interface, everything is fine. Don Sannella University of Edinburgh References: Robert Harper. Introduction to Standard ML. Report ECS-LFCS-86-14, University of Edinburgh (1986). This is an excellent informal introduction to the language, including the modules facilities, with examples. This is available from the Computer Science Department, Univ. of Edinburgh, Edinburgh EH9 3JZ Scotland, but it costs 5 pounds. David MacQueen. Modules for Standard ML. Proc. ACM Symp. on LISP and Functional Programming, Austin (1984). An early version of the modules facilities. A bit hard to read, but maybe easier to get your hands on than the report by Harper. Ake Wikstrom. Functional Programming using Standard ML. Prentice-Hall (1987). This textbook is based on ML but doesn't include anything about modules unfortunately. Don Sannella and Lincoln Wallen. A calculus for the construction of modular Prolog programs. Proc. 1987 IEEE Symp. on Logic Programming, San Francisco. This is what you get if you apply the same ideas to Prolog.