[fpc-pascal] Food for thought - language string improvement
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Thu Jul 6 23:03:02 CEST 2017
On 06/07/17 20:00, Sven Barth via fpc-pascal wrote:
> On 06.07.2017 16:13, Graeme Geldenhuys wrote:> Imagine if FPC had type inference and multi-line strings, neither very> exotic features. The code then becomes:> > =========================================> var query := '''SELECT Customers.CustomerName, Orders.OrderID> FROM Customers> FULL OUTER JOIN Orders> ON Customers.CustomerID = Orders.CustomerID> ORDER BY Customers.CustomerName;'''> > FDQuery1.SQL.Add(query);> =========================================> > > Easier to read, easier to edit, no need for a IDE wizard or external tools.
> Completely ignoring the type inference which I'm definitely not a fan of- at least not in Pascal: In my opinion it would be better to improveand finalize the $IncludeStringFile patch from issue #25536 (https://bugs.freepascal.org/view.php?id=25536 ).It has the advantage that it doesn't change the language and that theinclude file can be viewed independently with an appropriate syntaxhighlighter (especially with more complex SQL statements - to stick withyour example - that is something that I'd really welcome).Of course it has the disadvantage that one can't easily add variables,but for things like this one can always pass the included string toFormat() and friends which in my opinion would be more cleaned up anyway.
Some sort of heredoc approach would seem reasonable and I think it might
be worth noting the PostgreSQL way:
RETURN ($1 ~ $q$[\t\r\n\v\\]$q$);
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the fpc-pascal