[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## [Axiom-developer] [Fraction]

**From**: |
Ralf Hemmecke |

**Subject**: |
[Axiom-developer] [Fraction] |

**Date**: |
Mon, 06 Feb 2006 06:14:24 -0600 |

Changes http://wiki.axiom-developer.org/Fraction/diff
--
++added:
Maybe this text should go into another place (where?), but the above code shows
some danger.
It says (look at the representation):
\begin{spad}
Fraction(S: IntegralDomain): QuotientFieldCategory S with
...
== LocalAlgebra(S, S, S) add
Rep:= Record(num:S, den:S)
...
\end{spad}
and in LocalAlgebra one can read
\begin{spad}
LocalAlgebra(A: Algebra R,
R: CommutativeRing,
S: SubsetCategory(Monoid, R)): Algebra R with
...
== Localize(A, R, S) add
...
\end{spad}
where
\begin{spad}
Localize(M:Module R,
R:CommutativeRing,
S:SubsetCategory(Monoid, R)): Module R with
...
==
add
Rep:= Record(num:M,den:S)
...
\end{spad}
If someone is going to change the Rep of Localize say
\begin{spad}
Rep := Record(somedata: SomeType, num: M, den: S)
\end{spad}
then I suspect the code of Fraction will not work anymore.
The implementation of LocalAlgebra is fine, since it does not introduce a Rep,
but in Fraction there should also be no appearance of Rep.
The implementation of Fraction should completely do without Rep (information
hiding)
since it should not know about the concrete representation of elements in the
domain
LocalAlgebra.
In fact, the Category for Localize(M, R, S) is not rich enough. It already
exports two functions
\begin{spad}
numer: % -> M
++ numer x returns the numerator of x.
denom: % -> S
++ denom x returns the denominator of x.
\end{spad}
but obviously its use in Fraction call for destructive functions
\begin{spad}
set!: (%, 'num', M) -> M
set!: (%, 'den', S) -> S
\end{spad}
--
forwarded from http://wiki.axiom-developer.org/address@hidden

**[Axiom-developer] [Fraction]**,
*Ralf Hemmecke* **<=**