Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-04

How are short/ansi strings implemented ?

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Skybuck Flying

Hello,

I've been wondering lately a little bit how the basic types are implemented.

Now byte, integer and so forth seem easy, these can be directly translated by the assemblers into machine instructions.

However pascal's string types, seem more of a special type, one could consider this a "software type" which is not really implemented by the instruction set and therefore requires some kind of software routines to make it work.

Furthermore it seems obvious to me for the compiler to be able to compile itself with string support that it needs some kind of units/source code which implements these string types in a self-supporting/self-hosting fashion so that it does not depend on the implementation of other compilers.

So my question about this is:

1. What units are responsible for the implementation of "pascal strings".

Second question will probably be automatically answered by 1 but I'll ask it just in case anyway:

2. Are these units part of the compiler or the rtl and please explain why.

My guess would be that:

1. these units would probably be part of the compiler, otherwise the compiler could not handle strings itself ?

or

2. I can also imagine a situation where the compiler would first be "string-less" and then it would first compile the rtl (which would contain the string types) and then later on it would do a re-compile of itself to introduce the strings for itself... though this last possibility seems a little bit more cumbersome... but perhaps it would have certain adventages as well or maybe just disadventages.

Such which one is it ? Some more clearification/explanation would be nice ;)

Bye,
Skybuck.

Reply by email

Hans-Peter Diettrich
to Skybuck Flying
However pascal's string types, seem more of a special type, one could consider this a "software type" which is not really implemented by the instruction set and therefore requires some kind of software routines to make it work.

Right. Some (dynamic...) data types require special support for allocation and other standard procedures, in the RTL. Furthermore the compiler may include some magic, i.e. transform certain syntactic constructs (operators...) into calls to these procedures.

DoDi

Reply by email