[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] [#112 Returned type of compiled function]
From: |
wyscc |
Subject: |
[Axiom-developer] [#112 Returned type of compiled function] |
Date: |
Fri, 04 Mar 2005 01:58:34 -0600 |
Changes
http://page.axiom-developer.org/zope/mathaction/112ReturnedTypeOfCompiledFunction/diff
--
??changed:
-
This following shows that functions in Axiom have types and a domain for
functions may be associated with an identifier.
\begin{axiom}
dom:=(INT->INT)
f:dom
f x == x-1
\end{axiom}
However, when the function is compiled, the returned type displayed may not
agree with its declared type or even its apparent compiled type and depends on
the input!
\begin{axiom}
f 3
f(-3)
\end{axiom}
This has nothing to do with the declaration of <code>f</code>.
\begin{axiom}
f(x:INT):INT==x-1
f(3)
f(-3)
\end{axiom}
Not even:
\begin{axiom}
f(x:INT):INT==(x-1)::INT
f(3)
f(-3)
\end{axiom}
Or even:
\begin{axiom}
g(x:INT):NNI == 2^(sign(x)*x)::NNI
g 3
\end{axiom}
The following deliberate "error" shows the Interpreter always assumes
<code>3</code> is of type <code>PositiveInteger</code>.
\begin{axiom}
f 3
f -3
\end{axiom}
Compare the type returned below for <code>g 1</code>, the retraction to
<code>PositiveInteger</code> is not done.
\begin{axiom}
g(x:INT): FRAC INT == 1/x
g 1
\end{axiom}
The difference may perhaps be due to the fact that the data structure of
<code>FRAC INT</code> is very different from <code>INT</code>, whereas the data
structure of <code>INT</code> is identical to that of <code>PI</code>. So the
explanation that the reason <code>1/1</code> is not retracted because
<code>retract</code> is not always possible is not the full story.
--
forwarded from http://page.axiom-developer.org/zope/mathaction/address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Axiom-developer] [#112 Returned type of compiled function],
wyscc <=