by octoberfranklin · 4y ago · 0 comments
The metalanguage is indeed purely functional. The object language (bash) isn't.
Edolstra's thesis advisor was the first to create a scannerless GLR parser:
https://en.m.wikipedia.org/wiki/Scannerless_parsing
The first versions of Nix used a scannerless GLR parser, because it's the only way to prototype sophisticated features like antiquotation without going completely mad. Once the syntax was completely locked down it was rewritten with a separate scanner and LR(something) parser, but they're intricately entwined. The scannerful, non-GLR parser is faster but basically frozen and extremely difficult to modify. Fortunately Nix's syntax has been exceptionally stable for the last decade or more.
True string antiquotation is a feature that every language should have, but unfortunately with current technology it forces you to choose between a slow parser or a fast parser that's almost impossible to modify.
Some languages have "string interpolation" which is a weaker, more fragile form of antiquotation.
By antiquotation you mean evaluating things inside ${}, which is a standard thing in many, many places, including shell and Javascript.
Meanwhile, https://nixos.org/manual/nix/stable/expressions/language-val... has gems such as this:
> Since ${ and '' have special meaning in indented strings, you need a way to quote them. $ can be escaped by prefixing it with '' (that is, two single quotes), i.e., ''$. '' can be escaped by prefixing it with ', i.e., '''. $ removes any special meaning from the following $. Linefeed, carriage-return and tab characters can be written as ''\n, ''\r, ''\t, and ''\ escapes any other character.