Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is System.String exactly in Delphi?

I maintain some pretty old Delphi code that in a specific unit uses EmptyString.

The compiler resolves it as

costant EmptyString = '' - from System.string

now i have no System.string.pas file in my hard disk, or .dcu so i am not able to know more about this.

I found in

C:\Program Files (x86)\Embarcadero\Studio\17.0\source\rtl\sys\system.SysUtils.pas

another similar constant:

{ Empty string and null string pointer. These constants are provided for
  backwards compatibility only.  }

  EmptyStr: string = '';
{$IFNDEF NEXTGEN}
  NullStr: PString = @EmptyStr;

At first sight it seems that EmptyStr and EmptyString were used in past only so they are somehow deprecate so better to use '' directly or define constants in the application that redefine them.

Now after upgrading a 3rd party component i realized that EmptyString is not resolved anymore.

My question is: what is System.String exactly? Why there is no a corresponding .pas file in rtl?

I googled without success.

Thanks.

like image 924
LaBracca Avatar asked Mar 04 '23 14:03

LaBracca


1 Answers

System.String is the type String officially defined in the System unit.

The string type is in fact an alias to the System.UnicodeString type. The documentation says it is defined as:

type String = UnicodeString;

In turn the documentation for UnicodeString says:

type UnicodeString = { built-in type };

There is no Pascal code to define the type, since it is a built-in or intrinsic type. All built-in types are officially regarded as being declared in the System unit, even though you cannot see their declarations in the Pascal source code for that unit.

like image 112
David Heffernan Avatar answered Mar 15 '23 14:03

David Heffernan