[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-developer] "has" and "with" (was curious algebra failure)
From: |
Ralf Hemmecke |
Subject: |
Re: [Axiom-developer] "has" and "with" (was curious algebra failure) |
Date: |
Tue, 14 Aug 2007 12:27:28 +0200 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20070728) |
Ok. How do tell Aldor that I do not care about the name I am only
interested in the anonymous body of a given category definition? I
thought I understood this, but I guess not. The discussion of the
'define' keyword in the AUG lead me to believe that that was what was
implied by it's use.
If I pass a category as a parameter to a constructor, e.g.
define D: Category == with
f: % -> %
C(X:Category):Category == with
if Integer has X then
...
A:C(D)
does X represent the named category (D) or just it's category-value
(with f: %-> %)? Does the meaning of X change if we omitted the
'define' keyword?
Can you explain to me how I can use this? Or what to read? :-)
Oh, I would nearly have said, you got me. But here is how you can do it.
Anyway, your are right, that "define" needs some more clarification.
woodpecker:~/scratch>aldor -grun -laldor aaa.as
Nil
Nil
-1
-2
woodpecker:~/scratch>aldor -grun -laldor -DNAMED aaa.as
"aaa.as", line 27: stdout << (foo(d)::Integer) << newline;
.............^
[L27 C14] #1 (Error) There are no suitable meanings for the operator `foo'.
Add "-fasy" to the command line and investigate the .asy file. You will
see that indeed D will be tested in the "if" statement of Cat if you say
Dom: Cat D == add ...
I am not sure whether that makes you happy, but I haven't used such a
construction before (category in an argument + conditional in terms of
that category).
Ralf
PS: Don't ask me why the compiler spits out the two "Nil"s (at compile
time). Anybody from Aldor.org knows?
---BEGIN aaa.as
#include "aldor"
#include "aldorio"
macro SIG == with {-: % -> %}
define D: Category == SIG;
Cat(X: Category): Category == with {
if Integer has X then {foo: % -> %}
new: Integer -> %;
coerce: % -> Integer;
}
#if NAMED
Dom: Cat D == add {
#else
Dom: Cat SIG == add {
#endif
Rep == Integer;
import from Rep;
new(i: Integer): % == per i;
coerce(x: %): Integer == -rep(x);
foo(x: %): % == per(2*rep(x));
}
main():() == {
import from Integer, Dom;
d: Dom := new 1;
stdout << (d::Integer) << newline;
stdout << (foo(d)::Integer) << newline;
}
main();
---END aaa.as
- [Axiom-developer] .spad, .input, .as and autocoercion, (continued)
- [Axiom-developer] .spad, .input, .as and autocoercion, Ralf Hemmecke, 2007/08/16
- [Axiom-developer] Re: .spad, .input, .as and autocoercion, Gabriel Dos Reis, 2007/08/16
- [Axiom-developer] Re: .spad, .input, .as and autocoercion, William Sit, 2007/08/16
- [Axiom-developer] Re: .spad, .input, .as and autocoercion, Martin Rubey, 2007/08/16
- [Axiom-developer] Re: .spad, .input, .as and autocoercion, Gabriel Dos Reis, 2007/08/16
- [Axiom-developer] Re: .spad, .input, .as and autocoercion, Martin Rubey, 2007/08/16
- [Axiom-developer] Re: .spad, .input, .as and autocoercion, Gabriel Dos Reis, 2007/08/16
- Re: [Axiom-developer] "has" and "with" (was curious algebra failure), Ralf Hemmecke, 2007/08/13
- Re: [Axiom-developer] "has" and "with" (was curious algebra failure), Ralf Hemmecke, 2007/08/13
- Re: [Axiom-developer] "has" and "with" (was curious algebra failure), Bill Page, 2007/08/13
- Re: [Axiom-developer] "has" and "with" (was curious algebra failure),
Ralf Hemmecke <=
- Re: [Axiom-developer] "has" and "with" (was curious algebra failure), William Sit, 2007/08/12
- Re: [Axiom-developer] "has" and "with" (was curious algebra failure), Bill Page, 2007/08/12
- Re: [Axiom-developer] A curious algebra failure, Martin Rubey, 2007/08/12
- Re: [Axiom-developer] A curious algebra failure, Gabriel Dos Reis, 2007/08/12
- Re: [Axiom-developer] A curious algebra failure, Gabriel Dos Reis, 2007/08/11
RE: [Axiom-developer] A curious algebra failure, Weiss, Juergen, 2007/08/12