Sign in Join

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

Mailing lists / fpc-devel / 2021-11

tkLString vs tkAString

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Marc Weustink

Hi,

I ran into an issue with a piece of ported Delphi (6) code and RTTI. Part of the Delphi code was based on strings with a RTTI type tkLString where in FPC the type appeared to be tkAString. Fixing this was easy, but it made me wonder what the difference is between them. From the documentation:
Source position: rttih.inc line 22
type TTypeKind = (
...
tkLString, Longstring property.
tkAString, Ansistring property.

So there is apparently a LongString type and an AnsiString type. However if you search (google) the documentation on LongString, you only find references to AnsiString.

My question: What is the difference (if any) ?

Marc

Reply by email

Michael Van Canneyt
to Marc Weustink
Marc Weustink wrote 19 lines
Hi, I ran into an issue with a piece of ported Delphi (6) code and RTTI. Part of the Delphi code was based on strings with a RTTI type tkLString where in FPC the type appeared to be tkAString. Fixing this was easy, but it made me wonder what the difference is between them. From the documentation: Source position: rttih.inc line 22 type TTypeKind = ( ... tkLString, Longstring property. tkAString, Ansistring property. So there is apparently a LongString type and an AnsiString type. However if you search (google) the documentation on LongString, you only find references to AnsiString. My question: What is the difference (if any) ?

This dates from long ago...

Longstring was an idea for a shortstring/ansistring kind of string - unlimited length but no reference counting.

But it was never fully implemented.

Michael.

Reply by email

Marc Weustink
to Michael Van Canneyt
Michael Van Canneyt wrote 30 lines
On Tue, 30 Nov 2021, Marc Weustink via fpc-devel wrote: > Hi, > > I ran into an issue with a piece of ported Delphi (6) code and RTTI. > Part of the Delphi code was based on strings with a RTTI type > tkLString where in FPC the type appeared to be tkAString. Fixing this > was easy, but it made me wonder what the difference is between them. > From the documentation: >  Source position: rttih.inc line 22 >   type TTypeKind = ( >   ... >   tkLString,  Longstring property. >   tkAString,  Ansistring property. > > > So there is apparently a LongString type and an AnsiString type. > However if you search (google) the documentation on LongString, you > only find references to AnsiString. > > My question: What is the difference (if any) ? This dates from long ago... Longstring was an idea for a shortstring/ansistring kind of string - unlimited length but no reference counting. But it was never fully implemented.

Ah, that explains. So technically the delphi tkLString is the fpc tkAString and the fpc tkLString does not exist.

Marc

Reply by email

Ondrej Pokorny
to Marc Weustink
Marc Weustink wrote 32 lines
On 30-11-2021 13:37, Michael Van Canneyt via fpc-devel wrote: > On Tue, 30 Nov 2021, Marc Weustink via fpc-devel wrote: >> Hi, >> >> I ran into an issue with a piece of ported Delphi (6) code and RTTI. >> Part of the Delphi code was based on strings with a RTTI type >> tkLString where in FPC the type appeared to be tkAString. Fixing >> this was easy, but it made me wonder what the difference is between >> them. >> From the documentation: >>  Source position: rttih.inc line 22 >>   type TTypeKind = ( >>   ... >>   tkLString,  Longstring property. >>   tkAString,  Ansistring property. >> >> >> So there is apparently a LongString type and an AnsiString type. >> However if you search (google) the documentation on LongString, you >> only find references to AnsiString. >> >> My question: What is the difference (if any) ? > > This dates from long ago... > > Longstring was an idea for a shortstring/ansistring kind of string - > unlimited length but no reference counting. > > But it was never fully implemented. Ah, that explains. So technically the delphi tkLString is the fpc tkAString and the fpc tkLString does not exist.

Yes:
https://docwiki.embarcadero.com/Libraries/Sydney/en/System.TypInfo.TTypeKinds

The RTTI in FPC differs a little bit from the Delphi's and therefore IFDEFs are needed in shared code. E.g. tkBool and tkUChar from FPC don't exist in Delphi either.

I assume MvC knows more details - that is just what I stumped upon.

Ondrej

Reply by email