TLWNN

From Esolang
Jump to navigation Jump to search

The Language With No Name is a programming language devised by User:Smjg. It has no name because names are not used in the language. In spite of this, "TLWNN" is frequently used as a placeholder for a name when talking about this language.

TLWNN is a dynamically typed stack-based language. It has two stacks: the main stack and the auxiliary stack. In the absence of names, all data and procedures are accessed through these stacks.

The only numeric type is the arbitrary-precision rational number. Characters are represented by their Unicode codepoints, and strings are represented by continued fractions.

TLWNN has a runtime library of arithmetical and other procedures. These procedures have, like TLWNN and everything else in it, no names.

Instructions

Instruction Description
! Pops the top object from the main stack and performs a type-dependent action: executes a procedure; outputs a number as a string according to the continued fraction representation; pops the elements of a packed stack onto the auxiliary stack.
< Moves the top object from the auxiliary stack to the main stack.
> Moves the top object from the main stack to the auxiliary stack.
* Duplicates the object at the top of the main stack.
\ Swaps the top objects of the main and auxiliary stacks.
& Packs the auxiliary stack into a single object on the main stack.
@ Discards the top object from the main stack.
[...] Creates a procedure consisting of the instructions within the square brackets, and pushes it to the main stack.

In addition, numeric literals (which may be integers or rationals in m/n notation) can be embedded in the code, which are simply pushed to the main stack.

Any letters in the code are comments.

Code examples

The following is an example of how to write the "Hello, world!" program in TLWNN.

72! 101! 108*!! 111! 44! 32! 119! 111! 114! 108! 100! 33! 10!

This more complicated program, which outputs a number of asterisks specified by the programmer, illustrates how to implement a loop.

!<<<@@>
Output 100 asterisks
[42!
\*\>1>! decrement the counter
*\[]<<<*>>\1>! check for termination
*! now do it again ]
*!

In order to loop, a procedure needs a copy of itself to duplicate and then call again; the instances of *! just inside and just outside the closing square bracket take care of this. The complexity is due to the need to move various objects around the stacks in order to do the counting.

Note also how TLWNN's comment syntax accommodates interesting possibilities: the line Output 100 asterisks does nothing but pushes the number 100 to the stack, but at the same time it explains the purpose of the program.

Computational class

TLWNN can simulate a Universal Register Machine, which is basically BF with a fixed number of unbounded memory cells. Since URM is known to be Turing complete [1], so is TLWNN.

External link