[fpc-pascal] Feature "Multiline strings" added
Michalis Kamburelis
michalis.kambi at gmail.com
Sun Jul 27 19:01:16 CEST 2025
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.
- Deprecate in FPC and Pas2js the "backtick version". That is, let the
compilers just generate a message like "Multi-line strings using
backticks are deprecated and will be removed in some future release.
We encourage to use instead syntax with 3 apostrophes, docs on XXX"
when it encounters such syntax.
- And then it is clear to users what to use in new code. And they can
easily upgrade their code, just follow compiler messages.
- And then in 2+ years maybe we can remove the old backtick version.
And everything is simpler :)
Again, I know it sucks that FPC/Pas2js effectively have to do
additional work (deprecation process etc.) to adjust to Delphi. I'd
love to fix this state of things long-term :)
Regards,
Michalis
More information about the fpc-pascal
mailing list