pets at students.cs.mu.oz.au
Sat Sep 27 11:11:28 AEST 1997
On Fri, 26 Sep 1997, Fergus Henderson wrote:
> > > The way to do this is to pass a argument specifying the direction:
> > Hmm. Is there any reason to do it that way rather than have two
> > different procedures?:
> Yes. Often much of the code will be similar, and only a small part
> of the code will depend on the direction.
> If the code for the two different directions is entirely different,
> then no, I suppose there isn't much reason to use a single predicate.
Here are two more reasons:
1) if you write *this* predicate as a single predicate rather than two, its
callers may be able to run in multiple different modes, rather than
requiring two different implementations. So even when the code for two
different directions of the same predicate is entirely different, you may be
able to share a lot more code if you code it as one predicate rather than
2) It's simpler for users to remember one predicate name rather than two,
and there's only one predicate to document. I find that the smaller and
more orthogonal you can make a module's interface (and still give the needed
functionality), the better.
-Peter Schachte URL: http://www.cs.mu.oz.au/~pets/
pets at cs.mu.OZ.AU PGP: finger pets at 126.96.36.199 for key
Do insects spend hours demammaling their programs?
More information about the users