[fpc-devel] Using double quotes
Mark Morgan Lloyd
markMLl.fpc-devel at telemetry.co.uk
Sat Feb 27 17:55:36 CET 2016
Marcos Douglas wrote:
> On Sat, Feb 27, 2016 at 6:38 AM, Mark Morgan Lloyd
> <markMLl.fpc-devel at telemetry.co.uk> wrote:
>> Marcos Douglas wrote:
>>> Is there any chance to implement in the compiler something link this?
>>>
>>> S := "
>>> insert into t (
>>> id, description
>>> ) values (
>>> 1, 'foo'
>>> )
>>> ";
>>>
>>> Did you see?
>>
>> No, I don't see. It looks like an ordinary string to me, except that you're
>> allowing it to extend over multiple lines somewhat like a unix
>> here-document.
>
> Here are the differences:
>
> This:
> S := "
> insert into t (
> id, description
> ) values (
> 1, 'foo'
> )
> ";
>
> instead of this:
> S :=
> 'insert into t ( ' +
> ' id, description ' +
> ') values ( ' +
> ' 1, ''foo'' ' +
> ')';
A better solution would be a variant of Format() that could define
repeated or indeterminate parameters, and that possibly allowed C-style
backslash escapes. In any case, looking at your usage case it's very
common to have inline variables, and again they'd be better handled by
Format.
Expecting somebody to rewrite the parser is probably not realistic, and
in any event there's probably better things to do with double-quotes
(e.g. modified semantics for Unicode).
--
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-devel
mailing list