[fpc-pascal] Feature "Multiline strings" added
Michael Van Canneyt
michael at freepascal.org
Mon Jul 28 15:48:52 CEST 2025
On Mon, 28 Jul 2025, Pierre Muller via fpc-pascal wrote:
>
>
> Le 28/07/2025 à 10:07, Michalis Kamburelis via fpc-pascal a écrit :
>> Michael Van Canneyt wrote:
>>> 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.
>>>
>>
>> I can see how this can get into a heated discussion (hopefully it will
>> not!) :) You have the last word when it comes to FPC decisions,
>> obviously. Still, let me try to present the case for "deprecate
>> backticks" again.
>>
>> The problem with your solution """if you don't like the backticks,
>> don't use them.""" -> is that it means we have 2 ways to achieve the
>> same thing in the Pascal language, to the end of time, and users
>> *will* get confused about them and we have 2x more work to explain it.
>> Things like indentation, crlf/native/etc., what happens with last line
>> -> they have now 2 different behaviors, and people who work with
>> various Pascal code (Pas2js, FPC, Delphi) will need to grok them both
>> and remember which {$xxx} affects which. This makes things harder --
>> to document, to teach, and to not confuse ourselves when reading alien
>> code.
>
> I think that a possible solution would be to allow to restrict the mode
> switch to allow
> only triple-quote or only backquote delimiter.
>
> The idea is simply to add:
> {$modeswitch multilinestrings triplequote}
> and
> {$modeswitch multilinestrings backquote}
>
>
>
> It is then probably legitimate to also add:
> {$modeswitch multilinestrings all}
> {$modeswitch multilinestrings none}
>
> Delphi mode can then use
> {$modeswitch multilinestrings triplequote}
>
> by default, which means that back-quote will still be refused by the
> compiler,
> unless explicit
> {$modeswitch multilinestrings backquote}
> or
> {$modeswitch multilinestrings all}
>
> is used.
>
> pas2js code using back-quote would then need an explicit
> {$ifdef FPC}
> {$modeswitch multilinestrings backquote}
> {$endif FPC}
> to get the compiler to accept that syntax...
>
> Michael, would that be OK for the Pas2js part?
For me this is OK.
Thinking about it: As far as I know, modeswitches do not accept an argument,
they are simple booleans ?
Instead we could have a {$MULTILINESTRINGSTYLE NNN} directive and a -Su<type> or -Sl<type>
command line switch, with the delphi mode forcing the 'triplequote' style.
Michael.
More information about the fpc-pascal
mailing list