Clever Geek Handbook
📜 ⬆️ ⬇️

False

FALSE is an esoteric programming language created in 1993 by Wouter van Ortmerssen with two goals, he said:

  1. so that you can write a compiler for it no larger than one kilobyte in size .
  2. come up with a syntax that would look like encryption , a random set of characters.

FALSE was one of the first esoteric programming languages, in particular, it served as a source of inspiration for the author of the famous Brainfuck language. It will not be a great exaggeration to say that it was with FALSE that the mod for esoteric programming languages ​​began.

However, FALSE is still a fairly practical programming language. Although it is distinguished by write-only syntax, it supports a reasonable set of operations, unlike the Brainfuck version of the Turing machine , not to mention such monstrous languages ​​as INTERCAL and Malbolge . The source of ideas for FALSE was Forth , its syntax also resembles that of the well-known dc calculator for UNIX (with reverse Polish notation ). One of the main sources of difficulty when programming on FALSE is the use of exotic punctuation marks (not separated by spaces) instead of fort words.

Content

Basic Operations

The arithmetic operations + , - , * , and / take the top two elements from the top of the stack and return there, respectively, the sum, difference, product or quotient. The underscore _ is the unary operation of changing the sign of a number on the top of the stack. Logical operations in FALSE are binary = , > , & , | and the unary operation of logical negation ~ .

Stack operations are quite exotic in FALSE:

  • $ - Duplicates the top of the stack (in fort DUP): 0 1 $ → 0 1 1
  • % - Deletes the top of the stack (DROP): 0 1% → 0
  • \ - Swaps the top two stack elements (SWAP): 0 1 2 \ → 0 2 1
  • @ - The cyclic permutation of the top three elements of the stack (ROT): 0 1 2 3 @ → 0 2 3 1
  • ø - Copy the nth element of the stack to the top (PICK): 7 8 9 2ø → 7 8 9 7

Variables and routines

Variables in FALSE are denoted by a single lowercase Latin letter (az), all variables are global .

To assign a variable a value (taken from the top of the stack), use the colon operation : so 3a: assigns a to 3. To put a variable on the stack, use a semicolon ; .

However, since FALSE is a stack language , variables are rarely needed to store ordinary numeric values. More often they are used as functions - they store lambda expressions , for example:

  [1+] i:

This definition of the function is an increment , and it is given the name i (everything that is between '[' and ']' is the lambda expression). An operation is used to execute a lambda expression ! , if it is stored in a variable, the call takes the form ;! .

Control Constructions

In FALSE, there are two control constructs if (denoted ? ) And while - # . Here are examples of their use:

  a; 1 = [3b:]?

If a = 1, set b to 3.

  [a; 1 =] [2f;!] #

While a = 1, apply the function f to the value 2.

I / O

Strings in FALSE are all that are enclosed between two quotation marks. " string cannot be put on the stack or stored in a variable, but it can be part of a lambda expression. When a string is executed, it is simply displayed. For example:

  a; 1 = ["unit"]?

To output an integer, use the dot operation . , to display the character - a comma,. To read a character, the ^ operation. Operation ß causes flush of input and output streams ( stdin , stdout ).

Example

Example definition of a factorial function on FALSE:

  [$ 1 = $ [\% 1 \]? ~ [$ 1-f;! *]?] F:

Implementation

FALSE was implemented as a 1024- byte compiler written in assembly language for 68000 processors and a portable interpreter written in C (an executable version for DOS is available on the site). There is also an interpreter and compiler implementation for 386 DOS on ANSI Forth .

JavaScript implementation of FALSE is also available [1] .

FALSE Options

There is a functional version of Strictly False written in ML . Another functional extension FALSE is the language F (Functional False) written in K (and the implementation of “pure” FALSE in the same language [2] ).

owl

The development of FALSE ideas is owl ( Obfuscated Weird Language ), developed by Antonio Maschio between 2005 and 2006. It differs from FALSE in a larger practical orientation, an expanded set of operations (with a different symbolic designation), the presence of work with strings, etc.

In particular, owl distinguishes between integer variables and function variables. The first are indicated in capital letters, the second lowercase. A comma is used to assign values ​​to both of them, and @ to get a value or start a function. In addition, there is 1 array in the owl virtual machine, the default length of which is 32Kbytes, for which the operations #, and #@ (as well as @, and @@ for functions).

? characters used as if and while ? and ! , these operations distinguish one or two lambda expressions on the stack. So if there are two lambda expressions ? works like if ... then ... else.

The operations ^ and : serve, respectively, for raising to a power and extracting the root. To work with the stack, use the following operations:

teamstack notationname in fort
$(n1 n2 - n2 n1)swap
%(n - nn)dup
;(n -)drop
'(x * nm - y * n)roll
`(x * nm - x * nn)pick

The characters of the brackets are used for input-output: ( and ) input and output of the character, { and } - input and output of the string, < - input of numbers (the operation is less absent, $> used instead).

owl also allows you to attach inc files _]inc.owl[ , or run external owl programs _[file.owl] .

In owl (which is more than unusual for esoteric languages), you can even insert comments in the program: lowercase, starting with # , or multi-line, placed between (* and *) . Line comments beginning with the # character allow you to use owl for use in shell scripts .

The owl interpreter is written in C and cross-platform. Under Windows, debugging and profiling capabilities are not supported, the _t function does not work to get the current time.

Now consider the program for outputting primes to false and its translation to owl:

false
  999 9 [1 - $] [\ $ @ $ @ $ @ $ @ \ / * = [1 - $$ [% \ 1 - $ @]? 0 = [\ $. '  , \]?]?] #
owl
  999 9 [1 -%] [$% 2 '% 2'% 2 '% 2' $ / * = [1 - %% [; $ 1-% 2 ']? 0 = [$%. 32) $]? ]?]!

The next example is a factorial calculation program.

  % 0> ~ [?!]? "Factorial of"%. "Is"% 1 = [; 1.] [% 1 - [% 1 = ~] [% 2 '* $ 1 -]!;.]?

Notes

  1. ↑ javascript FALSE interpreter Archived November 25, 2010.
  2. ↑ False! in K

Links

  • Wouter's Wiki: False Language - FALSE Homepage
  • FALSE Language Guide
  • Owl language page
Source - https://ru.wikipedia.org/w/index.php?title=FALSE&oldid=98653260


More articles:

  • Lange, Andre
  • New Village (historical district, St. Petersburg)
  • Newcastle's Discovery Museum
  • Canon EOS 7D
  • StrongDC ++
  • Shilgan, Antonin
  • Weiss, Joseph (chemist)
  • Yamato 1
  • Mikhailovsky Rural Settlement (Krasnosulinsky District)
  • Ust-Kan (Altai Republic)

All articles

Clever Geek | 2019