jimbaker / tagstr

This repo contains an issue tracker, examples, and early work related to PEP 999: Tag Strings
51 stars 6 forks source link

Initial specification PEP #17

Closed jimbaker closed 3 months ago

EmilStenstrom commented 1 year ago

Another inspiration, if you want more than js tagged template literals, are sigils in Elixir: https://elixir-lang.org/getting-started/sigils.html

gvanrossum commented 1 year ago

Another inspiration, if you want more than js tagged template literals, are sigils in Elixir: https://elixir-lang.org/getting-started/sigils.html

Hm. That sounds like something quite different. Here's an example from the page you link -- these are all ways to spell the same regex:

~r/hello/
~r|hello|
~r"hello"
~r'hello'
~r(hello)
~r[hello]
~r{hello}
~r<hello>

I don't think Python is looking for this level of strangeness.

rmorshea commented 1 year ago

We could certainly point to it as an example of another language which has a similar feature. However, sigils differ syntactically, as Guido pointed out, as well as from the perspective of implementation because (from what I can tell) interpolation is achieved by defining the sigil as a macro.

EmilStenstrom commented 1 year ago

I should have linked to the custom sigils part at the end of the document: https://elixir-lang.org/getting-started/sigils.html#custom-sigils where you type ~tag"something" and can have a custom method sigil_tag that runs any code based on that. It was not a suggestion to follow their lead, but a way to say that JS is not alone in having support for "tag functions".

rmorshea commented 1 year ago

I managed to find this articular from TC39 (the ECMAScript standards organization) unfortunately the link to the full proposal is broken and I've been unable to find it - this list of finished proposals doesn't go back to 2015 when the template strings were originally accepted. The proposal's original champion, Mike Samuel, is still around though. Might be worth reaching out to see if he has any information on the original proposal that we could take advantage of.

EmilStenstrom commented 1 year ago

@rmorshea It seems template strings were called Quasi-literals before, so the spec is tied to that name. Also seems the site where the specification was hosted is down. Luckily, web archive saves the day, with this save link from 2017: https://web.archive.org/web/20170114115928/wiki.ecmascript.org/doku.php?id=harmony:quasis

It's similar in content to this blog post which is still up: https://2ality.com/2011/09/quasi-literals.html

pauleveritt commented 3 months ago

@jimbaker I believe we've incorporated everything we can from this PR and the discussion. I propose closing the PR.

jimbaker commented 3 months ago

Incorporated in a later PR, since merged.