Dashes
Twelve commands, and every one of them is a dash.
DigitalDetective47, 2021 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
DigitalDetective47 made Dashes in 2021. Its commands are the hyphen-minus and eleven other dash characters from Unicode, among them the hyphen, the non-breaking hyphen, the figure dash, the en and em dash, the minus sign and the two-em and three-em dash. Several of them look alike. Any other character is a comment.
Read the story
Underneath is a small machine. A stack holds whole numbers of any size, and a tape of them runs without end in both directions. Values move between the two through the current cell.
The machine
| Char | Code point | Does |
|---|---|---|
- | U+002D | Push 1 |
‐ | U+2010 | Push the next input character, or -1 at the end |
‑ | U+2011 | Pop and print it as a character |
‒ | U+2012 | Pop and drop |
– — | U+2013, U+2014 | Move the head left or right |
⁃ | U+2043 | Pop, add the current cell, push |
− | U+2212 | Negate the top |
⸺ | U+2E3A | Pop into the current cell |
⸻ | U+2E3B | Push the current cell |
― | U+2015 | Pop, and if it is 0 jump past the matching ⎯ |
⎯ | U+23AF | Jump back to the matching ― |
Popping an empty stack stops the program with an error, and so does printing a value below 0 or above 1,114,111.
Example
The cat.
The cat. It tests each character plus one, which is 0 only at the end of input, where ‐ gives -1. Its two short loops run at most once, so they work as an if, and each leaves a 1 or a 0 on the stack for the outer loop to test.
-⁃⸺ adds one to the current cell, and ⸻⁃⸺ doubles it. So 65 is 1 doubled six times, plus 1, and ⸻‑ prints it.
The infinite loop is -―-⎯. It pushes a 1 before every test.
From brainfuck
The specification shows that Dashes is Turing complete with a table that turns each brainfuck command…
The specification shows that Dashes is Turing complete with a table that turns each brainfuck command into Dashes.
| brainfuck | Dashes |
|---|---|
< > | – — |
+ | -⁃⸺ |
- | -−⁃⸺ |
. | ⸻‑ |
, | ‐⸺ |
[ | ⸻― |
] | ⸻⎯ |
[ pushes the cell for ― to test, and ] pushes it again before it jumps back to that same test. The usual brainfuck Hello World of 106 commands becomes 268 dashes, and they print Hello World!
Patterns it teaches
- Hostile design: the commands are hard to tell apart on purpose.
- Stack machines: every value passes through the stack.
- Turing completeness: shown by a translation from brainfuck.
Further
See also
Cell-based
Stack-based
Write your own in Run Convert a program from Dashes
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: dashes.
Command line
shib run dashes -e '‐⸺-⁃—⸻–-⁃―⸻‑‒-—⸻–⎯―‐⸺-⁃—⸻–-⁃―⸻‑‒-—⸻–⎯⎯' --input 'Hello, world!'shib manual dashesSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/dashes.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org