[fpc-pascal] Feature "Multiline strings" added
Michael Van Canneyt
michael at freepascal.org
Mon Jul 28 09:04:49 CEST 2025
On Sun, 27 Jul 2025, Michalis Kamburelis wrote:
> Michael Van Canneyt wrote:
>>> Let's delete custom very special FPC variant with ticks. leave only Delphi
>>> variant, please. in English it is maybe called as 'align implementation with
>>> Delphi'.
>>
>> It is aligned with Delphi ?
>>
>>> why? to keep the same source when changing objfpc/delphi mode.
>>
>> As said, pas2js alread has this, and I want to maintain compatibility between
>> FPC and pas2js.
>>
>> The used mode has no influence on the support for backtick or not.
>> Both variants will work in objfpc mode.
>>
>
> I'd say that (while I understand the reasons it happened) having 2
> ways in the language to do the same thing -> makes things more
> complicated.
>
> Why?
>
> - Some documentations will want to mention 2 ways of doing multi-line
> strings in FPC,
>
> - Some users will have to understand these 2 ways of doing multi-line
> strings in FPC -- because they will encounter some code using 1
> approach, some using different approach. They will need to also
> understand the reasons for both approaches ("this one works only in
> Delphi, this one works only in pas2js").
>
> - A bugs may "creep in" when users (us!) confuse some things. E.g.
> `{$MULTILINESTRINGLINEENDING ..}` doesn't affect Delphi-style
> multi-line strings, while `{$TEXTBLOCK ...}` doesn't affect FPC-style
> multi-line strings. If a code will use a mix of backtick and '''
> syntaxes for multi-line strings (which it shouldn't, but over time ->
> complicated things happen in big production codebases) then it's going
> to be a mess to understand. Imagine debugging something, only to
> realize that "ups, {$MULTILINESTRINGLINEENDING...} doesn't apply here,
> it's Delphi-style...".
>
> - Something that only you can judge: maintaining 2 ways of multi-line
> strings in FPC likely makes it harder on FPC. You need to document,
> you need to fix bugs in both, you need to carry them both working
> through all changes.
>
> To be clear, I fully understand the reasons why it happened, pas2js of
> course could not predict that Delphi will later invent it's own,
> incompatible, way of multi-line strings. The way to solve this is
> probably outside of the scope of this thread, you know I'm working on
> it :) Basically, better communication through standardization.
>
> That said, the solution to maintain 2 ways forever seems unoptimal. Is
> maybe proposition below possible?
>
> - Implement in Pas2js also Delphi-compatible multi-line strings.
That's already since long the case.
Personally, I prefer the backtick solution.
The triple quote is slow, it requires postprocessing the string.
The backtick solution needs only one pass.
<rant>
I positively HATE it when people start treating whitespace as
significant. No YAML or Python for me on that account alone.
The triple quote solution (presumably Python inspired)
is a totally braindead and retarded solution as far as I am concerned.
</rant>
You can guess from that little rant that I myself will certainly not
remove or even deprecate the backtick version.
If having one soluton for all is the norm, we need to remove a lot more
things from FPC that Delphi did differently than we do. We don't do that either.
Compatibility, yes. But that should not prevent us from doing things our own
way from time to time.
The solution is simple:
if you don't like the backticks, don't use them.
Michael.
More information about the fpc-pascal
mailing list