Falsish

== Falsish: a FALSE variant inspired by fish ><>==
Falsish is a superset of FALSE with the following major changes (among numerous others):
* Input and output flushing is automatic.
* Assembly functionality is omitted.
* The '`' (back quote) character instead enables an alternate function of the following character.
* ',' in addition to printing a number as a character, will also print a variable name, string, or lambda function.
* Lowercase letters are local variables, specific to a data stack.
* Uppercase letters are global variables.
* You create a new stack by using 'N(', where N is the number of items from the current stack to populate onto the new stack. This becomes the current stack.
* Each stack has its own local variables. Creating a new stack copies the initial elements into variables a, b, c..., with 'a' being the lowest stack element.
* You delete the current stack (and local variables) by using ')', which moves the remaining items onto the lower stack.
* '®' reverses the current stack, effectively making it a deque.
* '¶' breaks out of the most recent while loop.
* '<name' is a named variable. Name must begin with a letter. Uppercase = global, lowercase = local. If the name ends with '!', it executes.
* Useful (sort of) error messages are introduced.
Note that, with the exception of the ` assembly command, existing FALSE programs will run in Falsish.
Falsish was created and implemented in Python by McChuck (talk)
==Commands==
This list of commands for Falsish is mostly copied directly from FALSE. Falsish is a superset of FALSE, so FALSE programs will mostly run correctly, except for the lack of 68k assembly programming.
===Alternate===
*`Enable an alternate function for the following character.
**`whitespace Break from the current lambda function quotation. Halt if already running at the base level.
**`` Halt the program.
===Literals===
*123 push an integer onto the stack
**`1.23 push a float onto the stack
* 'c push the character code for c onto the stack
===Stack===
*$ DUP (A -> AA)
*% DROP (A -> )
*\ SWAP (AB -> BA)
*@ ROT (ABC -> BCA)
*ø PICK dup the Nth item, where 0 is the top of stack (ABC2 -> ABCA)
*© PUT (ABCD2 -> ADBC)
*™ ROLL (ABCD2 -> ACDB)
*£ OVER (ABC -> ABCB)
*® Reverse the stack (note that this effectively turns the stack into a sort of deque) ABCD -> DCBA
**`® Reverse a string. Numbers are unaffected.
*( Create a new stack and local variable array, populating it with the top N elements from the previous stack. It also copies the new stack elements into local variables, with the lowest being stored in a.
*) Drop the top stack and local variables, move the stack contents to the next lower stack.
*‡ Clear the current stack.
**`‡ Print the current stack on its own line.
*§ Push the current stack depth onto the stack.
**`§ Push the string length of the top element onto the stack. Numbers have length 0.
===Arithmetic and logic===
*+ Addition
*- Subtraction ex: 2 1 - --> 1
** Multiplication
*/ Integer division ex: 3 2 / --> 1
**`/ Float division
*_ Negate (negative numbers are entered "123_")
===Comparison and logic===
False is 0. True is anything else, specifically -1 so bitwise operators can be used.
*> Greater than (numbers and strings) ex: 3 5 > --> 0
**>~ Less than ex: 3 5 >~ --> -1
*= Equal (numbers and strings) ex: 2 2 = --> -1
**=~ Not equal ex: 2 2 =~ --> 0
*& Bitwise AND (integers only) ex: 0 1 & --> 0
*| Bitwise OR (integers only) ex: 0 1 | --> 1
*~ Bitwise NOT (integers only) ex: 0 ~ --> -1
===Lambda function quotes and flow control===
*[...] Define and put a lambda function (quotation) onto the stack.
**`[ Convert the top element into a lambda quote.
**`] Convert the top lambda into a string.
*! Execute lambda function quote.
*? IF conditional ex: Boolean [true]?
** If Boolean is true (non-zero), execute [true lambda]
** IF-ELSE can be expressed as: Boolean $[true]?~[false]?
*¿ IF-ELSE conditional: Boolean [true lambda][false lambda]¿
*# WHILE loop ex: [condition][body]#
** while [condition lambda] evaluates as true (non-zero), execute [body lambda].
*¶ Break from most recent while loop (but not the current lambda function).
*`whitespace Break from the current lambda function. Halt if at the lowest level.
**`` Halt the program.
===Variables===
*a-z Push a reference to one of the 26 available local variables onto the stack.
*A-Z Push a reference to one of the 26 available global variables onto the stack.
*: Store into a variable.
*; Fetch from a variable.
*< Named variable. First character must be a letter. Lowercase = local, uppercase = global.
** Creation: value <"name" or [lambda] <"Name" 
*** MUST end in whitespace!
** Use: <name pushes the name onto the stack, so you can then use ; or : as normal.
** Auto-execute: If name ends in '!', it will automatically execute when called instead of pushing its name onto the stack.
===I/O===
*^ Read a character, push its value onto the stack.
**`^ Input a string.
*, Write a character, variable name, or lambda function.
*. Write top of stack as a number.
*"string" Write a string (may contain embedded newlines).
**`"string" Push a string onto the stack.
*ß Flush buffered input/output (not needed, but implemented).
**`ß Convert all numbers represented as strings on the stack into actual numbers.
===Other===
*{...} Comment, not nestable
**`{ Unpack a string onto the stack as its component characters, with its length at the top of stack.
**`} Pack the top N stack elements into a string.
* Whitespace is ignored, and may be needed to separate consecutive integers
**`Whitespace is a break.
== Example programs ==
 {Factorial}
 [$1=~[$1-f;!*]?]f:
 5$f;!
 \"Factorial of "." is: ".10,
 {Alternating reverse}
 0 1 2 3 4 5 6 7 8 9 10
 10 1+$(n:[n;1-$n:0>][.32,®]#‡).10,
 {output: "10 1 9 2 8 3 7 4 6 5 0\n"}
 {autoexec variable}
 ["Good morning, sunshine! The earth says 'Hello!'"] <"salutation!" 
 <salutation!
== See also ==
* FALSE
* Fish
* Listack
== External resources ==
* Falsish interpreter written in Python
* Wouter's FALSE webpage
McChuck (talk) 11:28, 4 November 2022 (UTC)
Category:Languages Category:Turing complete Category:Low-level Category:Implemented Category:Stack-based Category:2022