esolang

Falsish

FALSE with a stack of stacks, after ><>. Each new stack brings its own variables.

McChuck, 2022 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: Factorial of 5 is: 120

The idea

McChuck made Falsish in 2022 as a superset of FALSE, inspired by ><>. Old FALSE programs still run, except for the ones that use FALSE's inline 68000 assembly. The backquote that FALSE kept for assembly now gives the next character a second meaning. `/ divides as floats, `"text" pushes a string where "text" prints one, and a backquote before a space leaves the running lambda.

Read the story

The biggest change is the stack of stacks. 3( moves the top three items onto a new stack, and its own variables a, b and c start as those three items. ) drops that stack and moves whatever is left on it back down. Lowercase variables belong to a stack; uppercase ones are global.

The machine

CharDoes
123 'c `1.5 | Push an integer, a character code or a float
$ % \ @Dup, drop, swap, rot
ø © ™ £ ®Pick, put, roll, over, reverse the stack
+ - * / _Arithmetic; / rounds down, _ negates
> = & \| ~Compare and bitwise, with -1 as true
[...] !Push a lambda; run it
? ¿ # If, if-else, while; leave the nearest while loop
a to z, A to Z, : ;Local and global variables; store, fetch
<"name" <nameStore into a named variable; push its name, or run it when it ends in !
N( )Start a stack with the top N items; drop it
‡ §Clear the stack; push its depth
^ , . "text"Read a character; write a character, a number, a text
{...}Comment

Integers never overflow, and , writes strings, variable names and lambdas as well as characters.

Example

The factorial.

The factorial. =~ is = and then ~, so it reads as not equal.

The alternating reverse puts 0 to 10 on the stack and moves eleven items onto a new stack, the numbers 1 to 10 and an 11 that n: keeps as a counter. Each round prints the top and reverses the stack, so the two ends take turns. The 0 stays on the first stack and comes out last.

Expected: 10 1 9 2 8 3 7 4 6 5 0

A named variable whose name ends in ! runs as soon as it is named.

Expected: Good morning, sunshine! The earth says 'Hello!'

Patterns it teaches

  • Stack machines: one stack per scope, pushed and dropped like frames.
  • Code as data: lambdas sit on the stack, and `] turns one into a string.

Further

Stack-based

Write your own in Run Convert a program from Falsish

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run falsish -e '{Factorial}
[$1=~[$1-f;!*]?]f:
5$f;!
\"Factorial of "." is: ".10,'
shib manual falsish

Source

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

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

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