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. For me, solving the above problem ("less confusion by not having 2 syntaxes for same thing") is really more important. ( It is *less* important for me which syntax for multi-line strings "wins", as I can see advantages and disadvantages in both. And it is unfortunate that effectively, since we are in this state, Delphi will not adjust to Pas2js, so the recommendation is to go with Delphi solution. Hopefully in the future we can have a better dialogue about it between FPC and Delphi. But that's a future dream, not something we have now. ) As for advantage / disadvantage of the Delphi solution: In general: calling a solution "totally braindead and retarded" is not constructive :) I know, your statement was in <rant> parentheses, still it wasn't very constructive for discussing :) Let's discuss exactly the technical pros and cons of this decision, for multi-line strings. The advantage of the Delphi solution, to make whitespace meaningful (*in this case*) is: you can write things like this: """ procedure Bar; const SomeHtmlContent = ''' <b>something</b> something something '''; begin end; """ ... and there will be no extra whitespace at the beginning of 3 lines in SomeHtmlContent. I don't have any internal knowledge about Embarcadero decision process, but I think that's why they chose this approach. They own examples happen to be similar to mine: https://docwiki.embarcadero.com/RADStudio/Athens/en/String_Types_(Delphi)#Long_and_Multiline_String_Literals . With backticks, to achieve the same, I need to write: procedure Bar; const SomeHtmlContent = `<b>something</b> something something`; begin end; ... which makes the indentation looks worse. 2x "something" is now at the same level as "begin". The possible mixups of whitespace is somewhat addressed by just requiring all lines to start with same indentation (it's an error if they don't). So.. 1. I don't think Delphi solution is so bad :) 2. Still, frankly I see both solutions (backticks or ''') as acceptable. 3. I still think that having 2 solutions to the same thing is bad for users. This is causing the confusion that I listed in my message. You need to document 2 ways of multi-line strings, users have to understand 2 ways of multi-line strings. We have 2x work to explain this to users. Choosing to deprecate backticks -> makes things clear for users. OK, we will have to live with 2 ways for some time (backward compatibility is important) but it's clear to everyone knows what to use in new code. We talk about it now, because probably *now* is the best moment to deprecate backticks, when they are only released in Pas2js (and in FPC since yesterday). If we don't, and FPC allows both versions, then in 5+ years we *will* have codebases using both approaches, so any thoughts about deprecation will be harder. And I'm not saying that FPC should now adjust to Delphi by removing all FPC-specific features. Let's not generalize :) Of course not, and there are good reasons why some FPC-specific solutions may be better than Delphi solutions (like @ for callbacks). I'd love to go into details, but that's for independent threads :) Here's let's focus on this very specific feature, multi-line strings. Both solutions seems to achieve in the end the same thing. Regards, Michalis _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal