Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2016-02

Using double quotes

13 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marcos Douglas

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 need to use 'string' + 'string + 'string'...

C# uses an "@" as a prefix, but Pascal don't use double quotes so, I think, we doesn't need it a "@", only double quotes.

Best regards,
Marcos Douglas

Mark Morgan Lloyd
to Marcos Douglas: Is there any chance to implement in the compiler something link this? S := " insert into…
Marcos Douglas wrote 11 lines
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.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]
Marcos Douglas
to Sven Barth: No. Sven
Sven Barth wrote 5 lines
Am 26.02.2016 21:21 schrieb "Marcos Douglas" : > > Is there any chance to implement in the compiler something link this? No.

Is there a good reason or you just don't liked? Thanks.

Marcos Douglas

Marcos Douglas
to Mark Morgan Lloyd: No, I don't see. It looks like an ordinary string to me, except that you're allowing it…
Mark Morgan Lloyd wrote 18 lines
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'' ' +

  ')';

Marcos Douglas

Ralf Quint
to Marcos Douglas
Marcos Douglas wrote 38 lines
On Sat, Feb 27, 2016 at 6:38 AM, Mark Morgan Lloyd 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'' ' + ')';

Why not simply write:

S := 'insert into t ( id, description ) values ( 1, ''foo'' )';

That also eliminates the problem with your "multi line string enclosed in double-quotes" problem of not being clear where and how many spaces are in that string...

Just my 2c as to why this is not necessary,

Ralf

---
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Marcos Douglas
to Ralf Quint
Ralf Quint wrote 7 lines
Why not simply write: S := 'insert into t ( id, description ) values ( 1, ''foo'' )'; That also eliminates the problem with your "multi line string enclosed in double-quotes" problem of not being clear where and how many spaces are in that string...

Was just an example. Imagine a huge SQL instead.

Best regards,
Marcos Douglas

Ralf Quint
to Marcos Douglas
Marcos Douglas wrote 10 lines
On Sat, Feb 27, 2016 at 1:49 PM, Ralf Quint wrote: > Why not simply write: > > S := 'insert into t ( id, description ) values ( 1, ''foo'' )'; > > That also eliminates the problem with your "multi line string enclosed in > double-quotes" problem of not being clear where and how many spaces are in > that string... Was just an example. Imagine a huge SQL instead.

Exactly!

Ralf

---
This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus

Mark Morgan Lloyd
to Marcos Douglas: On Sat, Feb 27, 2016 at 6:38 AM, Mark Morgan Lloyd Here are the differences: This: S := "…
Marcos Douglas wrote 37 lines
On Sat, Feb 27, 2016 at 6:38 AM, Mark Morgan Lloyd 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]
Sven Barth
to Marcos Douglas: Is there a good reason or you just don't liked? Thanks. Marcos Douglas
"Marcos Douglas" wrote
On Fri, Feb 26, 2016 at 8:12 PM, Sven Barth
Show quoted text 7 lines
> Am 26.02.2016 21:21 schrieb "Marcos Douglas" : >> >> Is there any chance to implement in the compiler something link this? > > No. Is there a good reason or you just don't liked? Thanks.

Mostly don't like, but also it introduces a ambiguity in the language especially since you could use your proposed variant in a single line as well.
I'd more prefer the $IncludeString directive for which there's still a patch waiting in Mantis. With this the contents would be in separate file, thus not only not cluttering the Pascal source, but also allowing the use of an editor with syntax highlighting as in your example with the SQL.

Regards,
Sven

Michael Van Canneyt
to Sven Barth
Sven Barth wrote 19 lines
Am 27.02.2016 17:44 schrieb "Marcos Douglas" : > > On Fri, Feb 26, 2016 at 8:12 PM, Sven Barth wrote: >> Am 26.02.2016 21:21 schrieb "Marcos Douglas" : >>> >>> Is there any chance to implement in the compiler something link this? >> >> No. > > Is there a good reason or you just don't liked? Thanks. Mostly don't like, but also it introduces a ambiguity in the language especially since you could use your proposed variant in a single line as well. I'd more prefer the $IncludeString directive for which there's still a patch waiting in Mantis. With this the contents would be in separate file, thus not only not cluttering the Pascal source, but also allowing the use of an editor with syntax highlighting as in your example with the SQL.

Exactly.

Michael.

Marcos Douglas
to Sven Barth: Mostly don't like, but also it introduces a ambiguity in the language especially since…
Sven Barth wrote 7 lines
Mostly don't like, but also it introduces a ambiguity in the language especially since you could use your proposed variant in a single line as well. I'd more prefer the $IncludeString directive for which there's still a patch waiting in Mantis. With this the contents would be in separate file, thus not only not cluttering the Pascal source, but also allowing the use of an editor with syntax highlighting as in your example with the SQL.

OK, $IncludeString directive sounds good. Thanks.

Marcos Douglas

vfclists .
to Marcos Douglas
Marcos Douglas wrote 19 lines
On Sat, Feb 27, 2016 at 3:06 PM, Sven Barth wrote: > Mostly don't like, but also it introduces a ambiguity in the language > especially since you could use your proposed variant in a single line as > well. > I'd more prefer the $IncludeString directive for which there's still a patch > waiting in Mantis. With this the contents would be in separate file, thus > not only not cluttering the Pascal source, but also allowing the use of an > editor with syntax highlighting as in your example with the SQL. OK, $IncludeString directive sounds good. Thanks. Marcos Douglas _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

The problem with $IncludeString is that it entails another level of indirection when you want to understand the source, which in this case happens to be text. After all the SQL used in a program happens to be part of the source code which is meant to be read by humans, even if it is not Pascal source. I don't know how difficult adjusting the compiler/syntax to handle this case is, or how well it fits with Pascal, but inline text if very useful and it is supported by a lot of languages, ie HEREDOC etc.

Frank Church ======================= http://devblog.brahmancreations.com