Programing Language: Self-Reference Problem in String Syntax (2024)

By Xah Lee. Date: .

self-reference problem in programing

there are many self-reference issues in programing, and in math.

here in particular, we are thinking about designing a string syntax, that needs to contain text of the source code itself, or using regex to search regex.

string delimiter self ref problem

one thing i noticed in past 10 years coding is the self-reference problem. e.g. suppose u design lang string delimiter. say, python triple quote

"""big text here"""

the triple quote is meant to avoid the delimiter appearing in the text.

good solution, until, you start to process python source code itself.

See also: Programing Language Design: String Syntax

using regex to search regex problem

ampersand encoding and html entities problem

See also: Google Code Prettify and Ampersand Encoding

solution

the string delimiter solution is here-string.

the solution for escape mechanism, and html entities, and ampersand encoding, is to simply not allow them.

the solution to regex regexing regex, is to not allow meta characters in regex.

all these are related. basicaly, you want to ban any escape mechanism, and use a random-string-like bracketing syntax.