[Aldor-l] Compiling setup
Christian Aistleitner
tmgisi at gmx.at
Sun Aug 13 03:28:20 EDT 2006
Hello,
> ---file crazy.as--
> #include "aldor"
> CrazyInteger: IntegerType with {string: Literal -> %} == Integer add {
> Rep == Integer;
> import from Rep;
> integer(l: Literal): % == per(integer(l)$Integer + 1);
> string(l: Literal): % == per 42;
> }
>
> main(): () == {
> import from TextWriter, Character;
> import from CrazyInteger;
> stdout << "This is crazy :" << space << 1 << newline;
> stdout << "This is crazy :" << space << 2 << newline;
> stdout << "Fourtytwo" + 4 << newline;
> }
>
> main();
> ---end crazy.as
>
> For me it says.
> >aldor -grun -laldor crazy.as
> 42 1
> 42 3
> 47
Just what I'd expect... Nothing fancy or crazy from my point of view.
> I cannot believe that Christian meant:
> > local litA: Literal := "abcdefghij"; -- (*)
> should be translated to
> > char * litA = "abcdefghij";
>
> First of all, the line (*) does not compile at all with libaldor. And I
> even don't know of a way to create a thing of type Literal.
> And also the C code is probably not right.
However, it really *is* what I meant. The line (*) compiles very well.
However, the compiler does not allow to use Literal directly. Every
Literal has to be converted using a string, integer, ... function. I
omittet it for brevity, but consider
#include "aldor"
string( l: Literal ): Literal == l;
local litA: Literal := "abcdefghij";
. It compiles and runs without any problems...
I cannot see any problems in the Aldor code I gave (of course I did not
specify the string function, but the mail was about conversion of a
Literal to C code. Therefore, I considered the trivial string function not
necessary to jot down.).
Just as Gaby, I cannot see any problems with the C code.
Are there any open issues with the code I gave?
> So if the (future) compiler puts literals into read-only memory, then
> the library definition
>
> string(l:Literal):% == string(l pretend Pointer);
>
> is the bug and must be changed.
Ja. Just as I said before.
--
Kind regards,
Christian
More information about the Aldor-l
mailing list