AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Delphi-PRAXiS - Lounge Delphi-News aus aller Welt [Yukon Beta Blog] Delphi Language: Modernizing String Literals
Thema durchsuchen
Ansicht
Themen-Optionen

[Yukon Beta Blog] Delphi Language: Modernizing String Literals

Ein Thema von DP News-Robot · begonnen am 18. Sep 2023
Antwort Antwort
Benutzerbild von DP News-Robot
DP News-Robot

Registriert seit: 4. Jun 2010
15.392 Beiträge
 
#1

[Yukon Beta Blog] Delphi Language: Modernizing String Literals

  Alt 18. Sep 2023, 17:10
This blog post is based on a pre-release version of the RAD Studio software and it has been written with specific permission by Embarcadero. No feature is committed until the product GA release. The official version is at*https://blogs.embarcadero.com/yukon-...ring-literals/

As with most other programming languages, Delphi’s Object Pascal allows a developer to use string literals, that is a string value written directly in the code. This is very common, even if not always recommended; it is better to use a* resource string since they offer advantages in terms of memory management and translation support for string to show to the user.*

Now string literals in Delphi have been tied since the early days to the original Turbo Pascal string type, which is the type we refer to today as “short strings”. Short strings have a maximum of 255 characters and are allocated directly as a static array. Delphi introduced dynamically allocated, long strings starting with Delphi 2. Initially long strings were based on Ansi, and later on Unicode. However, string literals never made the same transition from the early days, and they have been limited to the short string type, and retained* a maximum of 255 characters.

The 12.0 version of Delphi (and RAD Studio) introduces a very significant set of changes to the way the Delphi compiler handles string literals.

Long String Literals

With the coming release, it will be possible to have string literals longer than 255 characters. There is no specific limitation in the compiler. However, the length of a literal string might still be constrained by the editor’s limitations of 4K characters per line. There is no change in syntax; you can simply have a literal string longer than 255 chars.



Above: A 600+ characters long string literal in the editor.

Multiline Strings

What’s more relevant is the second extension to string literals is Delphi 12 will add support for multiline strings. In this case, you have to adopt a different syntax:* multiline strings are delimited by a triple #34e (’’’).

There are a few more syntax rules for a multiline string :

  • It is introduced by a triple #34e (’’’)*and*a new line (so no text following the triple #34es on the same line)
  • It can encompass multiple lines of the source code file (with no limitation)
  • It ends with a closing triple #34e (’’’) in a line without any text preceding it
What’s significant, compared to the past, is that there is no need to concatenate the lines into single-line strings with a + sign. Here is an example:
</br>*



Above: A multiline string literal in the editor.

Want to try now?

These features are enabled in the current Yukon beta, available to customers with an active update subscription. If you are in that group and haven’t received an invite, you can contact an Embarcadero sales rep or sales partner and ask for the signup link.

If you don’t have an active subscription, you can consider*buying*a new license or*contacting sales, and once you have a license you can ask* to join the beta.

This blog post is based on a pre-release version of the RAD Studio software and it has been written with specific permission by Embarcadero. No feature is committed until the product GA release.



Weiterlesen...
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:12 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz