axiom-developer
[Top][All Lists]

[Axiom-developer] Re: [Axiom-math] (no subject)

 From: Ralf Hemmecke Subject: [Axiom-developer] Re: [Axiom-math] (no subject) Date: Mon, 20 Jun 2005 17:03:57 +0200 User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

```In axiom you need to use records:

foo(a: Integer, b: Integer): Record(s: String, r:Integer) == ("sum", a+b);
```
```
```
Oh, interesting. I would have thought that your line gives a syntax error. At least according to the axiom book pp 141 (Section 2.4) one should write
```
foo(a:Integer,b:Integer):Record(s:String,r:Integer)==["sum",a+b];
u := foo(7,11)
u.s
u.r

```
The Axiom interpreter seems to be clever enough to correctly convert ("sum", a+b) into the record ["sum", a+b].
```
```
For programming, however, I prefer the Aldor way where it gives on your line above the following ...
```
--- begin multi.as
#include "aldor"
#include "aldorio"
import from Integer;
foo(a:Integer,b:Integer):Record(s:String,s:Integer)==("Sum",a+b);
--- end multi.as

aldor -grun -laldor multi.as
"multi.as", line 11:
foo(a: Integer, b: Integer): Record(s: String, s: Integer) == ("Sum", a+b);
...............................................................^
[L11 C64] #1 (Error) Have determined 1 possible types for the expression.
Meaning 1: String, AldorInteger
```
The context requires an expression of type Record(s: String, s: AldorInteger).
```
Ralf

```