* Best way to dispatch on two arguments
@ 1999-01-23 14:18 Juan Jose Garcia Ripoll
0 siblings, 0 replies; only message in thread
From: Juan Jose Garcia Ripoll @ 1999-01-23 14:18 UTC (permalink / raw)
To: Caml list
Hi,
I'm trying to code a library of mathematical operations among matrices,
vectors, polynoms, etc. I know OCaml does not have generic methods so
now the question is what is the best way to dispatch on two arguments?
I've thought of two possible implementations
1) Creating a single type of the form
type = Matrix of ([int],float array) | Real of float |...
and doing a large sequence of pattern matching.
2) Creating classes and defining one method for each binary operation.
Now my questions are
3) When using (1) I would like to hide implementation issues without
adding additional indirections. Thus, is it possible in OCaml to sum
abstract types such as in
type = matrix | real |...
where Matrix, Real, etc, would be abstract types defined in separate
modules?
4) Is (2) really possible? OCaml's methods are not polymorphic, so how
should I code that binary operation method? What type should it be so
that it admits any kind of mathemtical entity I define?
Regards
Juanjo
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1999-01-24 14:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-23 14:18 Best way to dispatch on two arguments Juan Jose Garcia Ripoll
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox