Post by Bigos
If I tried to untangle my mind, what programming style constraints
would you suggest?
In OO programming some people suggest to do a project without using IF
but using the object system.
You mean the polymorphism decides what function is used?
Say you have a category and objects A, B, C. Then a coproduct of
A and B is an object (written A+B) such that there are injections
iA : A -> A+B and iB : B -> A+B and for any two morphisms f : A -> C
and g : B -> C there is a unique morphism [f,g] : A+B -> C such that the
following diagram communtes ( g = [f,g] o iA, f = [f,g] o iB):
A -iA -> A+B <- iB- B
\ | /
\ [f,g] /
g\ | /f
v v v
[f,g] is the if-then-else or a polymorphism or a generic function in
lisp I guess. A,B,C are OO objects classes.
Taking Seibel's  shape example:
(defgeneric draw (shape)
(:documentation "Draw the given shape on the screen."))
is the polymorphism or if-then-else.
(defmethod draw ((shape circle)) ...)
(defmethod draw ((shape triangle)) ...)
are the morphisms f and g.
I'm not sure what C might be.
Perhaps with multimethods A+B is replaced by a polynomial like
(A1+A2) x (B1+B2+B3).