Summatciin
Summatciin is an esolang by User:BoundedBeans which depends on summations to do looping.
Syntax
Parentheses in Summatciin are replaced with double square brackets (just to be different).
All statements end when they encounter a double question mark.
A variable declaration (one of two statements in this language), takes the form:
let (name): (expression)??
A file can be imported with:
import (URI)??
Yes, a URI. You are allowed to import from the internet, or even a data URI (the type of the data URI should be text/plain
). In this URI, @@@@@
is replaced with the current path of directories leading to the current file, without an ending slash.
(file:///@@@@@/lib.txt
will use the file lib.txt in the same folder, with localhost as the host)
Names in this language can take one of these schemes:
(lowercase letter) (uppercase letter)_(literal integer) #(sequence of uppercase letters)# [reserved for built-ins]
Variables inside of namespaces can be accessed and reassigned, but only if the namespace has been assigned to a variable. It uses this form:
(namespace name)\(inner name)
The namespace name #THIS#
refers to the enclosing namespace.
Names without that refer to global variables. If you want to modify variables local to the current namespace, use #THIS#
.
The function #ENCLOSED#
, when applied to a number n, refers to the namespace n levels of enclosing above #THIS#
. When applied to 0 or a negative number, it refers to #THIS#
. You can assign it to a variable to access it. Note that this returns the same namespace object, so changes to the result will result in changes otherwise.
The inner name could be another namespace access.
Built-ins starting with Z are reserved for custom built-ins depending on the implementation.
Newlines, carriage returns, vertical tabs, and form feeds are completely removed from the code before running. Tabs are replaced with spaces.
Types
There are a few types in this language.
- Namespaces
- These are declared between
{(
and)}
. Inside there are a series of variable declarations (imports are illegal here; they must be global). Inside, HTML entities will be decoded after the statements have been split, and must be used for question marks and ampersands. If it is a literal, it will be executed before doing anything with the value to determine the initialization of the variables. - Namespaces can be nested.
- Namespaces can define the function
O_'0x1
. This overrides the addition operator. It should take in an argument nameda
as this namespace (which could of course be modified), and an argument namedb
as the right hand side.
- These are declared between
- Integers
- Encoded as hexadecimal, in the form
0x(hex digits)
. They can have a negative in front of them, but instead of a hyphen, it should be an apostrophe.
- Encoded as hexadecimal, in the form
- Functions
- Encoded in the form
{{(parameter names separated by commas);(namespace)}}
. The namespace value namedr
will be returned. The namespace will automatically define the parameters as variables inside of itself. The namespace, unlike a regular namespace, will not be executed until the function is called. The namespace may only be a literal namespace (otherwise how would it not be evaluated?).
- Encoded in the form
Operators
There are very few operators:
+ - Addition of two numbers. Applying the function O_'0x1 in the namespace. Applying a function on the left hand side to a namespace on the right. The values in the namespace should share the names with the parameters in the function. This has the highest precedence. This is not commutative or associative, unless you're dealing only with integers. ^ - The summation operator. Takes in a function on the left side, and a namespace on the right. The namespace should include a variable x (which is the starting value), and i (which is the ending value). The function should take in a single parameter, x, which is a namespace containing the current index in variable x. (Can be accessed with x\x) It's a namespace because it makes it a references, allowing x to be reassigned, which this operator will check for and skip back or forwards. Note that if it skips back, all results between the current point and the backwards point will be deleted, preventing a memory leak. It will go through each of the numbers, apply the function to them, and finally apply the addition operator to all of them. This has the second highest precedence. This is not commutative or associative.
Built-ins
#THIS#
- Refers to the current namespace.
#ENCLOSED#
- This is a function that taken in a number n, and returns the namespace n levels of enclosing above
#THIS#
. When applied to 0 or a negative number, it refers to#THIS#
- This is a function that taken in a number n, and returns the namespace n levels of enclosing above
#OUT#
- This is a function that takes in a number
o
and a numberf
. It will print it as an ascii character if f is 0, and as a number if f is 1. Anything not specified will print nothing. It returnso
.
- This is a function that takes in a number
#IN#
- This is a function that takes in a number
f
. If f is 0, it inputs as an ASCII character. If f is 1, it inputs as a number. Anything not specified will not input.
- This is a function that takes in a number
#IF#
- This is a function that takes in three parameters,
a
,b
, andc
. If a is not the number zero, b will be returned, otherwise c.
- This is a function that takes in three parameters,
#MULTITHREAD#
- This is a function that takes in two functions,
a
andb
. It runs these two functions in parallel.
- This is a function that takes in two functions,
#DECIMAL#
- This is a function that takes in a number,
n
. It returns 10^(-n) if n is positive or zero and -(10^(n)) if n is negative. Using addition, you can form decimal numbers out of these.
- This is a function that takes in a number,
#FILE#
- This is a function that takes in two functions,
a
andb
. It runs a, but redirects output to a string that will be used as a file path. It then runs b, but redirects output to that file. It returns the content of the file before it was written, as a function that takes in a numberi
and returns the byte of the file at that index as a number.
- This is a function that takes in two functions,
#OPERATINGSYSTEM#
- This is a number: 1 if the operating system is Windows, 2 if it is Mac, 3 if it is Linux, 4 if it is Chrome OS, 5 if it is iOS, 6 if it is Android, 7 if it is not determinable or not applicable, and 0 if it is something else.
#DATETIME#
- This is a namespace:
D_0x1
is set to the year,D_0x2
is set to the month,D_0x3
is set to the day,T_0x1
is set to the hour,T_0x2
is set to the minute, andT_0x3
is set to the second. This obviously should be different depending on when it is accessed (not constant).
- This is a namespace:
Examples
Hello world
let L_0x1: {( let #THIS#\o: 0x6C?? let #THIS#\f: 0x0?? )}?? let O_0x1: {( let #THIS#\o: 0x6F?? let #THIS#\f: 0x0?? )}?? let h: #OUT# + {( let #THIS#\o: 0x48?? let #THIS#\f: 0x0?? )}?? let e: #OUT# + {( let #THIS#\o: 0x65?? let #THIS#\f: 0x0?? )}?? let l: #OUT# + L_0x1?? let l: #OUT# + L_0x1?? let o: #OUT# + O_0x1?? let s: #OUT# + {( let #THIS#\o: 0x65?? let #THIS#\f: 0x0?? )}?? let w: #OUT# + {( let #THIS#\o: 0x77?? let #THIS#\f: 0x0?? )}?? let o: #OUT# + O_0x1?? let r: #OUT# + {( let #THIS#\o: 0x72?? let #THIS#\f: 0x0?? )}?? let l: #OUT# + L_0x1?? let d: #OUT# + {( let #THIS#\o: 0x64?? let #THIS#\f: 0x0?? )}?? let e: #OUT# + {( let #THIS#\o: 0x21?? let #THIS#\f: 0x0?? )}??
Truth-machine
let t: #IN# + {(let #THIS#\f: 0x0??)}?? let F_0x1: #IF# + {( let #THIS#\a: t?? let #THIS#\b: {{; {( let #THIS#\r: {{ x; {( let #THIS#\x\x: 0x1?? let #THIS#\r: #OUT# + {( let #THIS#\o: 0x1?? let #THIS#\f: 0x1?? )}?? )} }} ^ {( let #THIS#\x: 0x1?? let #THIS#\i: 0x2?? )}?? )} }}?? let #THIS#\c: {{; {( let #THIS#\r: {{ x; {( let #THIS#\r: #OUT# + {( let #THIS#\o: 0x0?? let #THIS#\f: 0x1?? )}?? )} }} ^ {( let #THIS#\x: 0x1?? let #THIS#\i: 0x1?? )}?? )} }}?? )}?? let a: F_0x1 + t?? let o: a + {()}??