Talk:2KWLang

From Esolang
Jump to navigation Jump to search

Are the Unicode double quotes (“” as opposed to "") part of the syntax, or are they unintentional? LegionMammal978 (talk) 13:13, 3 April 2020 (UTC)

They were unintentional. I will fix that. PythonshellDebugwindow (talk) 14:55, 14 April 2020 (UTC)

Computational class

A 1-register minsky machine program can be simulated:

start with: import 0
increment: + 1
decrement and check if 0: put the entire thing so far in parenthesis and type:
  == 0 ? (jump1) : (jump2)
multiply by constant: * (constant)
divide by constant: put the entire thing so far in parenthesis and type:
  % (constant) == 0 ? (jump1) : (jump2)
Jump1 should start with the operation, decrementing or division

The major problem with this approach is that expression data will not be carried over to the jumped file. But you could write the entire expression again inside of a print statement and ask the user to reinput that number if that counts. (You would also need input to detect numerics and put them in as numbers for that to work.)

Long story short: If user interaction is allowed to be used for Turing-completeness, and numerical input is available, then 2KWLang is Turing-complete. Otherwise, 2KWLang loses all data whenever looping is used, and cannot emulate all finite-state automata.

BoundedBeans (talk) 02:51, 27 August 2022 (UTC)

This post is inaccurate in recent times since the language was radically altered in 2024 (in a really good way). 2KWLang now actually has the potential for true Turing-completeness without input since you can store data in files. Although the data would have to be code itself that would be executed when it needs to be read, Underload shows this to not be a barrier to Turing-completeness. BoundedBeans (talk) 15:42, 2 June 2024 (UTC)
Actually, I don't think there's a need for the Underload strategy. As I think the Finite Looping Counter example demonstrates, we can use redirection followed by an import to make eval, then eval a file read, math, then redirection to get consistent access to numerical data. Then we can use more eval to generate file names on the fly with an integer parameter, positive or negative. From there we have the mechanism for a Turing-machine tape. BoundedBeans (talk) 15:52, 2 June 2024 (UTC)

I think 2KWLang (the current version) is Turing-complete because it can be translated from the 2-register minsky machine.

Temporary files: Temporary files cannot be created easily since 2KWLang cannot overwrite files, but we can use unary to do that.

=main.2kwl!
print "a" | "" > "unary.2kwl";
print import import print "unary.2kwl";
=unary.2kwl
a
=aa.2kwl
hello

In the explanation below, temp.2kwl will be used to replace temporary file names for simplicity.

Conditions: The new version cannot implement condition directly, but if the syntax import import print filename were allowed, conditions could be implemented by writing the condition into a file, and import the content of the file, like this:

=main.2kwl!
print (1+1)==2 | "" > "temp.2kwl";
print ".2kwl" | "" > "temp.2kwl";
import import print "temp.2kwl";
=0.2kwl
print "No";
=1.2kwl
print "Yes";

Accumulators: You can use files to contain accumulators in unary. As such, incrementing can be easily done via concatenating the file content by another character, like this:

=main.2kwl!
print "a" | "" > "accumulator.2kwl"
=accumulator.2kwl
aaaaaaaaaa

Subtraction: 2KWLang cannot remove content from files, however, you can use two accumulators to represent one accumulator. If you wanna subtract, increment the other accumulator (Just like in some games the opponent's score increases when you lose). Comparing the accumulator to 0 can be done by comparing the contents of the two accumulators representing this accumulator.

Control flow: 2KWLang does not have goto statements, but you can use import statements to do control flow. You can separate each command in the minsky machine program into a file, jump can be done by importing the file that represents the target instruction.

That is my not very rigorous proof, please point out if you found any mistakes.

btw I think the finite looping counter is incorrect as the print "string" > file appends the value to the file instead of overwriting it. --None1 (Nope.) 12:46, 13 September 2024 (UTC)

Your proof seems right as far as I can tell. (There actually is a way to remove content from files (print "" > file clears the contents of file), but that doesn't matter much in this case since there isn't a way to remove only a single character.) I'll update the Computational class section.
The finite looping counter uses print "" > file to overwrite files, so infinite appending shouldn't be an issue (although given the current lack of an interpreter, there's no guarantee that it isn't broken for some other reason). —User:PythonshellDebugwindow (talk) 20:22, 18 September 2024 (UTC)

Comparison operators

In what context can the comparison operators be used, and what sort of value do they return?

I'm also interested in whether statements like print 4 > 3 are interpreted as comparing 4 with 3, or trying to output 4 to the file 3 (which would presumably fail because 3 is not a string). --ais523 18:00, 17 September 2024 (UTC)

I am not the author of this esolang so I don't know for sure, but I think the best case is that the interpreter tries to run the code correctly. Since the outputting to file syntax must accept a string as second operand, and less than syntax must accept an integer. So I think the interpreter might interpret print 4 > 3 correctly as greater than, without any ambiguity (But my tc proof doesn't use greater than anyway). Also I think comparison operators return integers because 2KWLang doesn't have bool. --None1 (Nope.) 09:59, 18 September 2024 (UTC)

The comparison operators can be used wherever the mathematical ones can, e.g. print 1 == 1 would output 1, and they return either 0 or 1 (thanks for pointing out that I'd missed this).
print 4 > 3 should actually be interpreted as trying to output 4 to the file 3, which would then fail. —User:PythonshellDebugwindow (talk) 20:22, 18 September 2024 (UTC)
So what can the greater sign do? --None1 (Nope.) 23:04, 18 September 2024 (UTC)
When used in a statement of the form print value > file, it signifies that value should be output to file; otherwise, it signifies comparison (greater-than). —User:PythonshellDebugwindow (talk) 01:32, 19 September 2024 (UTC)