[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-developer] [MutualRecursion] (new)
From: |
Ralf Hemmecke |
Subject: |
Re: [Axiom-developer] [MutualRecursion] (new) |
Date: |
Wed, 19 Jan 2005 12:30:48 +0100 |
User-agent: |
Mozilla Thunderbird 1.0 (X11/20041209) |
One cannot do
> print(typeOf(1)::OutputForm)
in Aldor, because OutputForm does not exist. Also I would not know what
typeOf(1) should be. The Aldor compiler determines the type of the
literal 1 according to what is in scope at the moment. That is why
The compiler will complain for the following file.
$ aldor one.as
"one.as", line 4: stdout << 1;
.......^
[L4 C8] #1 (Error) There are 2 meanings for the operator `<<'.
Meaning 1: (TextWriter, AldorInteger) -> TextWriter
Meaning 2: (TextWriter, MachineInteger) -> TextWriter
--- one.as
#include "aldor"
import from TextWriter, Integer, MachineInteger;
stdout << 1;
-- end one.as
It cannot determine the type of 1 since there it could be address@hidden or
address@hidden (which is SingleInteger in Axiom speak).
Saying
stdout << address@hidden;
will compile and output 1.
Leaving out 'import from MachineInteger' would be fine, too.
I agree, that this behaviour leads to more typing sometimes to make the
types clear to the compiler, but I appreciate very much that there is
nobody in the middle (like an interpreter) who decides for me. The
interpreter might guess my intentions and be right in most cases, but
what if not? How am I going to find this out then? Who is going to point
me to the problematic code?
Ralf
William Sit wrote:
Peter Broadbery wrote:
I can not give a simple example right now but I suspect that
this happens very frequently in Axiom's algebra.
All over - try OutputForm as an example.
Yes, that is probably (that is, not yet investigated) the cause for the oneliner
stack overflow crash (wonder if it would also cause Aldor to have a stack
overflow):
print(anydomain::OutputForm)
such as
print(Integer()::OutputForm)
and more reasonably (actual code for debugging, say):
print(typeOf(1)::OutputForm)
This seems to be mutual recursion with no end, thus stack overflow.
William
RE: [Axiom-developer] [MutualRecursion] (new), Page, Bill, 2005/01/18