Comment by 90s_dev

Comment by 90s_dev 2 days ago

9 replies

Your library looks great. But a tangential rant about t-strings, using lexical scope for placeholder lookup is just a terrible, terrible design. It should be explicitly passed in a dictionary. I'm not sure why they made this decision.

jitl 2 days ago

If they’re gonna do that why bother making a new concept? You could already build(normalString, someDict)

Like why make me state “A goes here, also the value of A is 1” when I can just say “1 goes here”? When I build an array or map, I just write the expression

{ key1: value1 }

I don’t need to write

build({ key1, value1 }, { “key1”: key1, “value1”: value1 })

Why should an sql literal be any different from an array or dictionary literal?

  • 90s_dev 2 days ago

    Yeah in retrospect it's identical to what JavaScript does with string literals. I don't know what I was thinking.

    • williamdclt 2 days ago

      No I think your point is valid, and is valid in JavaScript too.

      Designing the “right” approach to look like the “wrong” approach (string concatenation) is a bad idea, however cute it is.

      It’s annoying that the wrong thing is the more ergonomic one, but at least it jumps out at any dev with any experience, they know what sqli risk looks like. With templated strings, it’s not so obvious anymore.

      • 90s_dev 2 days ago

        `...` and fn`...` in JavaScript are just syntactic sugar for function calls, the former for array.join(...) and the latter for fn(...) so there's no issue with these utilizing the current scope since that's what all function calls do.

    • 90s_dev 2 days ago

      Oh wait I know why. It's because the PIP had no specialized syntax highlighting to show that it was getting the variables from scope. So I started reasoning about it differently than I do about JS string literals, rather lazily too, and ended up thinking of something like emacs's dynamic scope or something. Amazing what syntax highlighting does to how we think.