KimL
Every statement is a call on one of five objects that are not really there.
Alexanderdna, 2011 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Alexanderdna began KimL in December 2009 in Visual Basic .NET and wrote it again in C# in July 2010. The third version, Specification 11.01 from January 2011, is the one in the specification. Its compiler and virtual machine are written in C++.
Read the story
Each line calls a method on a pseudo-object. io reads and prints, var declares and sets variables, stack works the k-stack, tape works a row of 128 cells and ctrl jumps. The objects hold nothing of their own. They group the instructions of what is underneath a small assembly language with typed expressions.
There are three types. An int has 32 bits, a real is a 64-bit floating point number, and a string is a row of 8-bit characters. Expressions mix them with operators on eleven levels of priority and 19 built-in functions. By convention a call takes its arguments on the stack, right to left, and leaves its result on the tape at 0, and the callee clears the stack.
The machine
| Object | Methods |
|---|---|
io | in reads a line as a type or into a variable; out prints |
var | decl, del and set |
stack | push, pop, peek, swap and clear |
tape | read, write, next, prev and move, on 128 cells |
ctrl | goto and call a label, each with an optional if; return; end |
A label is a name and a colon on a line of its own, and ; starts a comment. / divides into a real and \ into an int, & joins two values as strings, and #( ) and @( ) turn a value into a real and an int. A variable has to be declared on an earlier line than the lines that use it, as the compiler checks.
Example
The factorial keeps n on the stack and calls itself with one less on top.
The factorial keeps n on the stack and calls itself with one less on top. Each return multiplies the value on the tape at 0 by the n it pops. io.out adds no line feed, so the prompt and the answer share a line.
The 99 bottles of beer program counts down from 99 with ctrl.goto loop if bot > 0 and ends by waiting for a line of input.
Patterns it teaches
- Stack machines: a call gets its arguments on the k-stack, and the callee clears them.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from KimL
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: kiml.
Command line
shib run kiml -e 'io.out "Hello World!\n"'shib manual kimlSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/kiml.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org