Valence
Jump to navigation
Jump to search
Valence is a programming language that brings the expressiveness of spoken language to code. Specifically, it adds two things: homonymy and structural ambiguity.
Concept
In Valence:
- Any symbol can be read as a variable name, an octal digit, a command, a type, or an expression
- For commands and expressions, most symbols have multiple interpretations based on parameter count
- Every possible reading of a program plays out in parallel
- Brackets can disambiguate a phrase when needed
Lexicon
Each instruction is a single letter, borrowed from Ancient Greek numbering and measuring signs. While there is some association between some borrowed signs and usage, they all mean something significantly different in Valence.
symbol | typed as | interpretation | type | params |
---|---|---|---|---|
π Ά | q | 0 | octal digit | |
π Ά | var | |||
int | type | 0 | ||
not | exp | 1 (exp) | ||
add | exp | 2 (exp, exp) | ||
while | cmd | 1 (exp) | ||
add_assign | cmd | 2 (var, exp) | ||
π | w | 1 | octal digit | |
π | var | 0 | ||
read_as_digit | exp | 1 (digit) | ||
subtract | exp | 2 (exp, exp) | ||
if | cmd | 1 (exp) | ||
while_queue | cmd | 2 (var, exp) | ||
π Ύ | e | 2 | octal digit | |
π Ύ | var | |||
read_as_var | exp | 1 (var) | ||
div | exp | 2 (exp, exp) | ||
end block | cmd | 0 | ||
goto | cmd | 1 (exp) | ||
trade_op | cmd | 2 (var, range): CURRENTLY IN PROGRESS | ||
π | a | 3 | octal digit | |
π | var | |||
queue | type | 0 | ||
equals | exp | 2 (exp, exp) | ||
cmd | 1 (exp) | |||
π | s | 4 | octal digit | 0 |
string | type | 0 | ||
int_or_floor | exp | 1 (exp) | ||
cast | exp | 2 (type, exp) | ||
label | cmd | 1 (var) | ||
assign | cmd | 2 (var, exp) | ||
π » | d | 5 | octal digit | |
π » | var | |||
char | type | 0 | ||
mult_by_eight | exp | 1 (exp) | ||
get_element (from queue) | exp | 2 (exp, exp) | ||
jump | cmd | 1 (exp) | ||
append | cmd | 2 (var, exp) | ||
π | z | 6 | octal digit | |
π | var | |||
bool | type | 0 | ||
or | exp | 2 (exp, exp) | ||
else | cmd | 0 | ||
else_if | cmd | 1 (exp) | ||
π | x | 7 | octal digit | |
π | var | |||
ratio | type | |||
dequeue | var | 1 | ||
mul | exp | 2 (exp, exp) | ||
input | cmd | 1 (var) | ||
mul_assign | cmd | 2 (var, exp) | ||
[ | [ | begin lexical group | ||
] | ] | end lexical group |
Example Programs
Hello World (with single interpretation)
[π]π[[π »]π[[π »[π »[ππ]]]π Ά[π »[ππ]]]] [π Ά]π[π Ύπ] [π]π Ά[[π »[ππ]]π Ά[ππ »]] [π Ά]π »[π Ύπ] [π]π Ά[ππ] [π Ά]π »[π Ύπ] [π Ά]π »[π Ύπ] [π]π Ά[ππ] [π Ά]π »[π Ύπ] [π Ύπ]π[π »[ππ]] [π Ά]π Ά[π Ύπ] [π]π[[[π »[π »[ππ]]]π Ά[π »[ππ Ύ]]]π Ά[ππ]] [π Ά]π »[π Ύπ] [π Ά]π »[π Ύπ] [π]π Ά[ππ] [π Ά]π »[π Ύπ] [π]π Ά[π Ά[π[π]]]
Links
- Valence interpreter
- Introduction to Valence as bsky thread
- Github repo