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.
- 1 System Description
- 2 Configuring the autosuggestions
- 3 The stack
- 4 Contractions
- 5 Command reference
- 6 Bytecode?
- 7 Syntactic sugars
- 8 Computational class
- 9 Examples
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-, 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 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 is the index. This is similar to
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.
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.
||Fill up autosuggestions|
||Select an autosuggestion|
||Add an autosuggestion|
||Delete an autosuggestion|
||Push the recent autosuggestion onto the stack|
||Return the stack|
||Index the stack|
||Reverse the stack|
||Load/store into the accumulator|
||Define a contraction|
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.
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 |
||||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.|
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.
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
DCS compiled to BIT
If this is incorrect, fixes are welcome.
DCS compiled to Chicken
This will be very easy to golf in!
DCS compiled to DCS
This is trivial, as every program in this compilation will trivially be a DCS self-implementation (it will call itself).
Substitute program here!