From Esolang
Jump to: navigation, search

Pronounced toons-whack, TEWNLSWAC is an idea for a programming language by User:Zseri. It's inspired by TEWELSWAC, but uses a very different syntax. The name stands for: The Esolang Where No Line Starts With A Colon.

TEWNLSWAC was created as a more golfed version of TEWELSWAC with additionally object orientation.

Memory Model

TEWNLSWAC is an internally stack based language, but uses variables in the frontend.

A symbol is an reference to a constant dynamically allocated container of data.

A variable is a name for a symbol. Any variables are global, but you can emulate local variables using objects.

All parameters to functions are passed via symbols.


Most lines of code are like this:

command args;

When a condition is specified, the syntax is:

(condition) { commands... }

When no condition is specified, the line is executed no matter what. All whitespace is supported.

The ; is used to separate commands. Newlines after this are not necessary.

Labels are just special commands, because they don't have a semi-colon as separator, but a colon:


A comment starts with // that goes to the end of the line.


Expressions are used within lines of code as conditions or arguments. They could be enclosed in ()s (parentheses). An example of an expression is 4 > 5 or A + 5. The expression will return a value. You can nest these.


Command List

Command Arguments Description
a variables list fetch arguments from argument stack
c: or ç target type, expression casting operator
c label, optional arguments in parentheses call function beginning at label, push current instruction pointer to the return stack
e none end the execution of the progam
g label skip to label
n identifier, code block in curly brackets namespace limiter
p expression print something without a newline
r optional expression pop instruction pointer from the return stack, go after the pointed instruction

Variable Assign Commands

The first argument is always a variable.


Command Description
= o assign an empty object to a variable
= ?? assign a null pointer to a variable (can only be compared via = and ?)


Command Second argument Description
= expression assign a expression value to a variable
.= identifier call a method on first arg, determinated by second arg, then assign the return value to first arg


The first argument is always an object variable, the second argument is always a identifier (identifies a key of an object).

First part Second part Third argument Description
. = expression assign a expression value to a variable of an object
. =& label assign a label to a variable (which is then a method) of an object


Cast operator keyword Name Internal representation
f floating point number double
i integer int
s string c++ std::string
object hashmap(std::string → symbol)

Operators only valid in expressions

Operator Compat Levels Description
Nullary operators
@ read a line from stdin (as string)
! read an integer from stdin
Unary operators
? 3 → 0 check if arg is set
Binary operators
= 3 → 0 check for equality
< 1 → 0 check for lesser than
> 1 → 0 check for greater than
+ 2 → 2 add
- 2 → 2 subtract
* 1 → 1 multiply
/ 1 → 1 divide (could raise division by null error)
% 0 → 0 modulo (could raise division by null error)
. 4 . 5 → 3 call a method on first arg, determinated by second arg

Operator Compatibility (Compat Levels)

Level Name integer float string object identifier
0 integer X
1 number X X
2 anything except object X X X
3 anything X X X X
4 higher types X X
5 abstract identifier X



_: p @ + '\n;
g _;

Fibonacci sequence

A = 0;
B = 1;
 p A;
 p '\n;
 C = A;
 A = B;
 B = B + C;
(C < A) { g LOOP; }
(C = A) { g LOOP; }


(0 = !) { g F; }
T: p "1\n";
g T;
F: p "0\n";

99 bottles of beer

B = 99;
A = " bottles of beer";
C = " on the wall";
D = "No more";
 p B;
 p A;
 p C;
 p ".\n";
 p B;
 p A;
 p ".\nTake one down, pass it around.\n";
 B = B - 1;
 p B;
 p A;
 p C;
 p ".\n";
(B) { g loop; }
p D;
p A;
p C;
p ".\n";
p D;
p A;
p ".\nGo to the store, buy some more.\n";
p 99;
p A;
p C;
p ".\n";

Object Orientation

 // based on zeiksh/examples/oopex.zkl
 Hello = o;
 Hello.say = &Hello_say;
 Hello.juge = &Hello_juge;
 Dog = Hello;
 Dog.juge = &Dog_juge;
 Hex = Hello;
 MyDog = Dog;
 a this;
 p "I say: ";
 p this.juge();
 p "\n";
 a this;
 r "Hello World!";
 a this;
 r "Wouff!";

Computational class

ABCDXYZ can be compiled into TEWNLSWAC, but ABCDXYZ's computational class is unknown. TEWNLSWAC is at least capable of simulating a Bounded-storage machine, but it is probably Turing-complete (prove needed).

See also

External Resources