tagstr icon indicating copy to clipboard operation
tagstr copied to clipboard

Initial specification PEP

Open jimbaker opened this issue 3 years ago • 6 comments

jimbaker avatar Sep 05 '22 19:09 jimbaker

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

EmilStenstrom avatar Jan 09 '23 22:01 EmilStenstrom

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.

gvanrossum avatar Jan 10 '23 00:01 gvanrossum

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.

rmorshea avatar Jan 10 '23 00:01 rmorshea

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".

EmilStenstrom avatar Jan 10 '23 14:01 EmilStenstrom

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.

rmorshea avatar Apr 23 '23 02:04 rmorshea

@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

EmilStenstrom avatar Apr 23 '23 07:04 EmilStenstrom

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

pauleveritt avatar May 22 '24 21:05 pauleveritt

Incorporated in a later PR, since merged.

jimbaker avatar May 30 '24 21:05 jimbaker