Dynamic Contraction System
Dynamic Contraction System is a system for golfing programming languages invented by User:A that are not specifically built for golfing in. It primarily uses non-visual bytes and is generally suited for golfing any programming language. (Although one may have a hard time golfing GS2, which is primarily bytecode-based...) It is very dynamic, as it allows the user to configure it as they wish. Please suggest anything that can help the user to program DCS more easily.
System Description
In order to help people golf their programs, autosuggestions should at least be implemented.. This part of the system allows entering shorter commands than they used to and makes the user's job easier.
It is very simple. The user types their "suggestion string" into the system. Then, they type !
, which helps them fill up their suggestions.
If the user wants to select a suggestion, they should use @x
, where x is the number of the suggestion. x is an integer in decimal form, and the suggestion ends in a non-decimal character.
This system requires inputting a list of provided command inside the language, which allows the user to configure the autosuggestions. This allows infinitely many variants made possible.
Configuring the autosuggestions
In order to configure the autosuggestions, the user can use x+
or x-
, where x is a string for autosuggestions, which is a string previously put onto the source code. Clearing the autosuggestions is trivial, as if the user does not need an autosuggestion, they do not have to use it.
The stack
The user can add suggestions or delete suggestions to the stack.
In order to add suggestions, use x(
to push something onto the stack (or possibly an autosuggestion, if the user uses autosuggestions), and use )
to return something from the stack and pop the stack.
In order to index the stack for suggestions, the user will use *x
, where x
is the index. This is similar to @x
.
In order to support more advanced features, the user can use ~
to reverse the stack. Also, the user can use &
to load/store into the accumulator.
Contractions
The user can also define contractions for the program.
In order to define a contraction using items on the stack, the user can use ^
, where the second-to-the-top item is defined to mean the top item.
Command reference
!
|
Fill up autosuggestions |
@x
|
Select an autosuggestion |
x+
|
Add an autosuggestion |
x-
|
Delete an autosuggestion |
x(
|
Push the recent autosuggestion onto the stack |
)
|
Return the stack |
*x
|
Index the stack |
~
|
Reverse the stack |
&
|
Load/store into the accumulator |
^
|
Define a contraction |
Bytecode?
All of the descriptions above are false, as practical compilation programs in Dynamic Contraction System should use bytecodes, in order to not affect the functioning of the host language.
!
|
0x01 |
@x
|
0x02 |
x+
|
0x03 |
x-
|
0x04 |
x(
|
0x05 |
)
|
0x06 |
*x
|
0x07 |
~
|
0x08 |
&
|
0x0B |
^
|
0x0C |
Syntactic sugars
Dynamic Contraction System has a lot of syntactic sugars (although there is currently a few of them):
` | or 0x0E | Push "Hello, world!" onto the stack |
=x | or 0x0F | Duplicate the previous suggestion x times |
+x+ | or 0x1A | Add a whole string between the +'s to the autosuggestions |
'...' | or 0x1B | Replace everything between the ' 's as their autosuggestions
|
| | or 0x1C | Pop the stack |
(x( | or 0x1D | Push x onto the stack |
¡ | or 0x1E | Reverse-suggestion. Reverse the string, and match from the list of autosuggestions, reversed. |
Computational class
This system alone is definitely not Turing-complete, as it cannot provide infinite loops. However, if the programming language that it compiles to is Turing-complete, then it is Turing-complete by simulation.
Examples
A user can compile to other Golfing languages, but that action will be thought as obviously cheating, as it will be trivially be that golfing language. (GS2 is an exception.)
DCS compiled to busybox
Hello, world!
ec! `)
DCS compiled to BIT
If this is incorrect, fixes are welcome.
Truth-machine
'LOCGOZZGOOIOLOZCPZLOOCPOGOO'
DCS compiled to Chicken
This will be very easy to golf in!
Cat program
( c!=()11)6)10
DCS compiled to DCS
This is trivial, as every program in this compilation will trivially be a DCS self-implementation (it will call itself).
Bootstrap
Substitute program here!