Procedural Footnote Language
A plain text with footnotes, where a footnote can count, compare, read input and cite itself.
Daniel Myers · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 6 known programs · Test method
Run it
The idea
Daniel Myers wrote the specification of PFL as a way to add structured footnotes to email and other text. A document is a body with delimiters such as [1], a [PFL1.0] line, the footnotes, and [PFLEND]. Reading it replaces each delimiter by its footnote, and a footnote may hold delimiters and functions of its own.
Read the story
One or two numbers after a footnote's number make it a program. [1:98] is worked out at most 98 times, so a footnote that ends by citing itself becomes a loop. [1:0:2] is worked out only from its second delimiter on, which lets a body cite a footnote once to skip it. [INDEX:1] counts how often footnote 1 has been worked out, and that count is the only memory there is.
The machine
| Text | Gives |
|---|---|
[n] | Footnote n, worked out |
[[] []] | A bracket as text |
[ADD:x:y] [SUB:x:y] | x + y, x - y |
[GT:x:y] [LT:x:y] [IS:x:y] | true or false |
[AND:a:b] [OR:a:b] [XOR:a:b] [NOT:a] | true or false |
[IF:c:x:y] | x if c is true, else y |
[INDEX:n] | How often footnote n has been worked out |
[INPUT] | A line of input |
[LEN:t] [HEX:c] [ASCII:h] | A length, a hex code, a character |
[ORD:n] [PRIME:n] | An ordinal such as third; true or false |
[RET] [SPACE] [TAB] [ABC] [HS] | A line feed, a space, a tab, the alphabet, Hi Sherry! |
[DATE], [TIME], [BEEP] and [USERDATA] are left out, as they need the machine or the user.
Example
The sum cites footnotes 1 and 2 in the body, where they are too early to be worked out.
The sum cites footnotes 1 and 2 in the body, where they are too early to be worked out. Footnote 3 cites them again; now each reads a line, and ADD adds them.
The 99 bottles is one footnote of one line that cites itself 98 times and works out each verse from [INDEX:1]. A second footnote holds the last verse.
Patterns it teaches
- String rewriting: a document is rewritten by replacing delimiters with footnotes until none are left.
- Counter machines: the proof that PFL is Turing complete keeps counters in pairs of empty footnotes and compares their
INDEX.
See also
String-rewriting paradigm
Write your own in Run Convert a program from Procedural Footnote Language
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: procedural-footnote-language.
Command line
shib run procedural-footnote-language -e '[1]
[PFL1.0]
[1:3] Wubba [1]
[PFLEND]'shib manual procedural-footnote-languageSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/procedural-footnote-language.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org