[fpc-devel] Some thoughts on multi-line string support, and a possible syntax that I think is perfectly clean and Pascal-ish.

Ben Grasset operator97 at gmail.com
Mon Jul 8 02:12:38 CEST 2019


Neat bit of trivia:

Multi line strings even work properly with Ryan's (Ryan Joseph that is)
very-cool-but-not-yet-merged-to-trunk
<https://bugs.freepascal.org/view.php?id=35140> generic constants patch.

With a build of FPC that includes both, you can do some really interesting
stuff:

program FunWithCurrentlyUnofficialLanguageFeatures;

{$mode ObjFPC}
{$modeswitch AdvancedRecords}
{$modeswitch MultiLineStrings}

type
  generic Tripler<const S: String> = record
    const Result = S + S + S;
  end;

begin
  Write(
    specialize Tripler<`
      A
      B
      C
      D
    `>.Result
  );
end.

The above program printing, as you might expect:

      A
      B
      C
      D

      A
      B
      C
      D

      A
      B
      C
      D

Can't do that in Delphi!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190707/edd656e1/attachment.html>


More information about the fpc-devel mailing list