Remix.run Logo
pphysch 3 months ago

> Unlike template strings, it was done in the language.

This is a disingenuous way to compare a LISP with a language that values syntactic convention and strives to be readable and maintainable by more than one person.

> I predict that Python will eventually get dedicated HTML syntax:

How do you assign this result to a variable? How is this any better than

    content: HTML = t"<p>Hello {name}</p>"
kazinator 3 months ago | parent [-]

It's a true statement; I made a usable construct that causes template strings to be turned into objects, rather than to perform the string substitution. I did it without changing any syntax, or have to ship a new version of the language.

Python has to ship a new version for this; there is no way for existing installations to use the code.

I don't have to change anything in my editor setup.

So who is it that values syntactic convention?

t"abc" is a syntax errror in vast numbers of existing Python installations; how can we call it convention?

> How do you assign this result to a variable?

That's to be worked out. The "html:" fantasy construct could have a way to do that. When you think of assigning to a variable, the first thing that comes to mind is "a = b" syntax. But, look, the define construct in Python also assigns to a variable:

  define fun(arg):
    ...
The imagined html construct could have arguments like to assign an object to a variable, or just spin out textual HTML into a specified stream. I don't want to get into it, but there are obvious ways it could be done such that it hits all sorts of requirements.

> How is it any better

It renders all of the following problems unrepresentable: mismatched angle brackets, mismatched or unclosed tags, bad attribute syntax, injection.