[Aldor-l] "has" semantics
Ralf Hemmecke
ralf at hemmecke.de
Mon Nov 5 17:40:24 EST 2007
Dear Stephen,
I thought that I understood the discussion at the Aldor Workshop, but
what I see here (in particular the first T and the last F) does not look
very consistent to me.
Could you tell whether the compiler is right or wrong according to the
intended language semantics.
Thank you.
Ralf
>aldor -fx -laldor HasSemantics.as
>HasSemantics
NNI has with -: % -> % ---- T
-(1 at NNI) = -1
INT has IntegerType --- T
NNI has IntegerType --- F
---BEGIN HasSemantics.as
-- 21-Aug-2007 AldorWorkshop + modifications.
#include "aldor"
#include "aldorio"
NNI: with {
+: (%, %) -> %;
coerce: Integer -> %;
<<: (TextWriter, %) -> TextWriter;
} == Integer add {
Rep == Integer;
import from Rep;
coerce(x: Integer): % == per x;
(p: TextWriter) << (x: %): TextWriter == p << rep x;
}
main(): () == {
import from Integer;
stdout << "NNI has with -: % -> % ---- ";
stdout << (NNI has with {-:%->%}) << newline;
a: NNI := 1::NNI;
if NNI has with {-:%->%} then {
b: NNI := -a;
stdout << "-(1 at NNI) = " << b << newline;
}
stdout << "INT has IntegerType --- ";
stdout << (Integer has IntegerType) << newline;
stdout << "NNI has IntegerType --- ";
stdout << (NNI has IntegerType) << newline;
}
main();
---END HasSemantics.as
More information about the Aldor-l
mailing list