esolang

Loader

No loops and no jumps. To do something again, a module loads a module, usually itself.

SuperJedi224, 2015 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 7 known programs · Test method

Run it

Expected: Hello, World!

The idea

SuperJedi224 made Loader in 2015. A program is a set of modules, one file each, and the run starts in the main one. A line can be skipped by putting a condition in front of it, but nothing ever goes back. The only way to repeat is load, which runs a module on a copy of the memory and gives back the value it yields. loadip runs it on the memory itself, so its changes stay.

Read the story

So every loop is recursion, and every pass of a loop gets its own copy of the variables.

The machine

Memory is variables named in capitals and a tape that runs both ways, all 32-bit integers that start at 0. A:print A prints A only when A is not 0, and A:~B: puts two conditions in a row.

InstructionDoes
set A,B =5Set variables, or *cells, and give the value
incr A decr *3Add or take 1 and give the new value
load name loadip nameRun name.ldr on a copy, or on this memory, and give what it yields
yield 5 exitLeave the module with a value; end the program
print A B printbool A printchar 72 105Print numbers, TRUE or FALSE, or characters, then a line feed
printf "%n is %c" A BPrint text with numbers, characters and booleans filled in
write "text" 0 printst 0 erase 0Put text on the tape, print it up to a 0, zero it
readline 0 @INRead a line onto the tape, or a number

-, ~ and * are negation, not and the tape cell. One source holds every module, and a line (name.ldr) starts the next one, as in the specification.

Example

The specification counts down from 100 with one module.

The specification counts down from 100 with one module. This is the same program from 5. The first pass sets A and B, and B stops every later pass from setting them again.

Expected: 5 4 3 2 1

The truth machine prints 0 and exits on 0, and on 1 loads itself forever. The cat reads a line, prints it, and loads itself for the next one.

Expected: 0
Expected: abc

A second module, and what load and loadip keep. The copy loses its change to Y, the memory itself does not.

Expected: 7 0 7 1

Further

Also in Strange time

Write your own in Run Convert a program from Loader

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: loader.

Command line

shib run loader -e 'printf "Hello, World!"'
shib manual loader

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/loader.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org