prql icon indicating copy to clipboard operation
prql copied to clipboard

Prune syntax of string literals, add d-strings and block strings

Open aljazerzen opened this issue 2 years ago • 5 comments

This is a followup for https://github.com/PRQL/prql/pull/3679#issuecomment-1763486217

At the moment, we have a lot of ways to specify plain string literals (not including s-strings or f-strings). Being a new language without many backward compatibility guarantees issued, I think we can cut some of those out.

As there is quite a few specific proposals here, I suggest we use this issue as the overview and talk about specific syntax in the separate threads. Not all are created yet, feel free to open up a new one.

All proposals at the moment are:

  • remove ' for quoting string (reason: unnecessary)
  • remove multiple-line strings (reason: they make lexer non-modular)
  • remove multiple-quote strings (reason: they make lexer non-modular)
  • add block strings #3783
  • add d-strings

aljazerzen avatar Nov 09 '23 11:11 aljazerzen

I do think that we should add either of block strings or d-string, but not both, since they provide very similar functionality.

aljazerzen avatar Nov 09 '23 11:11 aljazerzen

Not a full reply, but:

remove ' for quoting string (reason: unnecessary)

I'm up for this iff we can find a way of representing inner " without escaping. Rust does this successfully with r#" as an example. Otherwise the escapes can become ugly and difficult...

max-sixty avatar Nov 10 '23 09:11 max-sixty

Can you describe what "modular" means in the following?

remove multiple-line strings (reason: they make lexer non-modular)

Why is this such a big problem?

snth avatar Nov 10 '23 11:11 snth

remove multiple-line strings (reason: they make lexer non-modular)

Why is this such a big problem?

I've written a bit about that here: https://github.com/PRQL/prql/issues/3783#issuecomment-1806048866

aljazerzen avatar Nov 12 '23 13:11 aljazerzen

One quick thought against removing ' quoted string literals: my SQL-inertia leads me to prefer ' over " when writing PRQL string literals because I've been conditioned by the fact that the two different quoting styles mean something completely different. Sure, it's just a matter of retraining, but I always appreciate when a language will graciously accept both common quoting styles without complaint.

kgutwin avatar Dec 13 '23 20:12 kgutwin