Description
This article is from the FAQ, by with numerous contributions by
others.
F02) How do I separate implementation and specification code?
Let us assume that we has the following source code:
ORIGIN '...'
--- lib: attributes ---
f: (# t: @text; i,j: @integer; r: @real
enter t[]
do (* ... some code implementing f ... *)
#)
This source code is assumed to reside in a source code file called
fSource.bet.
If we want to separate the implementation and the specification, we can make
the following change to fSource.bet:
ORIGIN '...';
BODY 'fBody'
--- lib: attributes ---
f: (# t: @text; i,j: @integer; r: @real
enter t[]
<<SLOT fBody: dopart>>
#)
That is, we have replaced the implementation with a slot specification.
We now create another source file; let's call it fBody.bet:
ORIGIN 'fSource'
--- fBody: dopart ---
do (* ... some code implementing f ... *)
As can be seen, we have now modularized the implementation away from the
specification (except for the i, j, and r attributes (see question F05).
 
Continue to:
Share and Enjoy
Bookmark this story so others can enjoy it:
Tags
programming