[mercury-users] polymorphism
Peter Schachte
pets at students.cs.mu.oz.au
Mon Sep 29 10:00:41 AEST 1997
On Sat, 27 Sep 1997, Bart Demoen wrote:
> > 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 two.
>
> Sorry for being slow, but I don't understand this: how can the code
> for two different directions of the same predicate be entirely
> different (at the source level) ? Isn't the only way by defining
> another predicate for the other mode ?
You can use Fergus's hack of passing an extra argument indicating the mode,
or define it with pragma c_code. Either way, the point is that if you do
either of these, then callers of your predicate may be able to run in
multiple modes, whereas if you define a separate predicate for each mode,
they won't.
-Peter Schachte URL: http://www.cs.mu.oz.au/~pets/
pets at cs.mu.OZ.AU PGP: finger pets at 128.250.37.150 for key
Do insects spend hours demammaling their programs?
More information about the users
mailing list