3 ms·
So, the f-string in Python is "spelled" that way because another leading character was the only ASCII syntax left for such a thing. It's odd that PRQL and now
by mixmastamyk 2y ago
So, the f-string in Python is "spelled" that way because another leading character was the only ASCII syntax left for such a thing. It's odd that PRQL and now potentially C++ might copy it. In the PRQL case it was a new thing so they could have chosen anything, double quotes (like shell interpolation) or even backticks, that seem to make more sense.
Also the f- prefix was supposed to be short for format and pronounced that way. But "eff" caught on and now devs the world over are calling them "eff strings" ... funny. :-D
- eviks 2y agoWhy is it odd to copy a popular and fitting alternative? What's the better one?
- mixmastamyk 2y agoBecause it’s an variant with a wart, only picked from being backed into a corner. I mentioned shell interpolation in my previous comment.
- snthpy 2y agoPRQL contributor here: That is a valid point and something I've also been thinking about lately. I can't speak for the others but in my case the Python string interpolation syntax was the one I was most familiar with, other than bash, so it was just the default. The big idea really is to have string interpolation and the syntax is somewhat secondary but we do aim for ergonomics with PRQL so it is a consideration. Since then I've seen more alternatives like `Hello ${var}!` in JS/TS and $"Hello {var}!" in F#. Not sure that there's a clear way to prefer one approach over the others. What would you consider to be factors that would make you prefer one over the others?
- mixmastamyk 2y agoI suppose simplicity and familiarity would be the primary two goals. Then congruence with SQL would be another factor specifically for PRQL.
- eviks 2y agosome factors: ease of typing: so regular quotes are better vs backticks (even with a prefix), F-prefix - better than $, requiring Shift ease of learning: here letter-mnemonic seems easiest: so I-prefix for "interpolation" or E-prefix for "expression" or maybe V-prefix for "variable". Or maybe F for "formatted" is also fine? familiarity: so F-prefix due to Python?
- lifthrasiir 2y ago> [...] another leading character was the only ASCII syntax left for such a thing. Not really? The original PEP [1] for example considered `i"asdf"` as an alternative syntax. Any ASCII Latin letter besides from `b`, `r` and `u` would have been usable. [1] https://peps.python.org/pep-0498/#how-to-denote-f-strings https://peps.python.org/pep-0498/#how-to-denote-f-strings
- mixmastamyk 2y agoAs an alternative to another leading ascii character, you offer another leading ascii character?
- mixmastamyk 2y agoWhy is this reply to someone who misunderstood downvoted?
- vitaut 2y agoWe could introduce g-strings instead.