[Aldor-l] Compiling setup

Gabriel Dos Reis gdr at integrable-solutions.net
Sat Aug 12 13:08:43 EDT 2006


Ralf Hemmecke <ralf at hemmecke.de> writes:

| Christian's mail was quite hard to read due to strange line breaks, but 
| I think he made an important point. If the compiler sees something like
| 
|    "blah"
| 
| in general it is even impossible to guess the type of that thing.

To my eyes, that is a literal string.

[...]

| 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.

Why would  the C code not right?

[...]

| You should not be misled by the fact that a library (like libaldor) 
| provides a type String. And the Aldor library, makes it implicitly clear 
| that strings are writeable, by providing a function
| 
|    set!: (String, MachineInteger, Character) -> String
| 
| 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.

That is essentially the difference betweenn

   char *litA = "abcdefghij";

and

   char strA[] = "abcdefghij";

litA points to a storage where resides string literal.  strA is an
array whose elementss  can be freely modified.

The first morally corresponds to Literal, and the second to String.

All major programming languages I know of that provide a modifiable
string type behave correctly when a string is initialized with a literal.

-- Gaby



More information about the Aldor-l mailing list