revo
revo, the programming language
docs | github
revo is a dynamic language made for the joy of programming
a 1mb toolkit with a ton of focus on ergonomics
introduction with words
get<br>or<br>try --><br>join the discord
⣄⠔⠄⡨⣀⣹⣥⣣⡚⣿⣓⣾⣫⣷⠮⡧⣬⣬⣑⢤⠤⡉⣿⡥⣂⢟⣕⡴⠬⠆⠸⡈⡆⠀⠀⠀⡋⠄⠂⠨⡆⠀⠠⠃⡀⠀⠀⠈⢰⣿<br>⠩⣽⢟⢭⠶⢷⢵⣻⠿⢍⣟⡅⡧⡭⣽⡯⡯⣶⠭⣽⡢⠱⢿⢧⠓⢥⠨⠧⠉⣡⠐⠀⢑⣀⠂⠈⠆⡅⠀⡀⢥⠤⢁⠀⢣⠀⠀⢘⠽⡏<br>⠬⡓⣼⢟⢜⡧⣷⣇⣧⡷⢯⣿⣿⣿⡶⣭⠍⣯⣻⢥⠞⣮⣬⣩⠅⢏⠆⠁⡀⠌⢩⡁⢁⠅⠡⢀⠠⠀⢉⢈⠀⠀⡅⠀⡇⠀⠀⠃⠭⣯<br>⡎⣟⣵⠅⣾⢭⣿⣾⣯⣿⣿⢿⣿⣿⣿⣿⣧⡳⣥⢜⣟⡤⠉⣁⢧⢨⠌⡂⠀⠒⠬⡪⣊⠄⠀⠘⠀⠢⡁⠀⡀⠅⠅⠀⡄⠀⠈⠀⢕⡟<br>⡕⣧⡗⠎⠷⣯⣿⣿⣷⣿⡻⢵⣿⣿⣿⣭⣿⡿⣟⣇⡧⣿⡭⢨⠫⠮⠄⠖⠀⠆⠦⠕⠁⠅⠀⠆⡁⠁⡀⠀⠄⡉⠁⠀⠄⡀⡂⠀⢼⣇<br>⠃⣶⣯⠢⡗⣟⣿⡿⣿⣯⢿⣷⢾⢿⣛⣿⣿⣯⡻⣾⡾⣾⢵⣏⣩⠅⠅⠥⠀⠃⠠⠅⠃⠀⡈⠀⠭⠅⠀⠀⠁⠔⠀⠀⢂⠅⠅⠀⠽⡇<br>⠱⣻⣻⡥⢫⢯⢿⣷⣷⣿⣿⢾⢿⣷⢯⣉⣟⣟⣾⣿⠳⣿⣇⣃⠯⠘⠔⡇⠒⠅⡖⠁⠄⠡⠑⣀⠀⡁⠀⡀⠃⠈⠀⠀⠅⠀⠀⠂⣋⡇<br>⢂⠵⣓⣿⣍⢯⢯⡯⣟⣝⠷⣟⢝⣋⡏⣧⠯⣿⣿⢯⣼⣯⡂⡂⣟⡧⠐⣅⠂⠥⠏⠀⠂⡅⠅⡁⠁⠄⠠⠊⠀⠨⠀⢈⠀⠄⠉⢘⡟⡆<br>⡥⣯⢌⡤⢽⣗⣏⠗⢿⣻⡭⡞⡷⣭⢿⡻⡯⡟⣕⣾⢽⢯⡭⠂⡍⠀⠏⠀⢌⠴⠂⠊⡄⢗⠂⠰⠀⠤⠣⠀⠀⠀⠁⠀⠀⠀⠅⠀⢕⡽<br>⠵⡭⡩⠋⠽⣽⡛⡹⢯⠍⡛⡏⣯⢟⠟⠿⣩⣳⡿⡟⢗⣭⡤⡯⠁⡬⠠⠂⢄⠂⢤⠀⢖⠀⠀⢀⠂⢖⠀⠘⠀⠀⠂⠡⢤⠠⠀⠀⣫⡿<br>⠀⢰⡇⢂⣃⠙⣧⡵⡙⠇⡷⠶⡷⠶⡟⡙⣩⡌⠯⡺⡍⡲⡸⣆⠼⠅⡱⠌⠡⠂⢄⣠⠃⠀⠀⡂⠈⠂⠠⢀⠀⠀⠀⠔⠀⠂⠂⠀⠨⣯<br>⡔⠰⠼⣝⢪⢋⢋⠣⣧⡦⣦⡁⡭⠽⡛⠁⡫⢡⡄⠿⡫⣕⣔⢳⠌⢡⡸⠁⠁⠂⣠⡇⠀⠀⠀⠍⠈⠄⠀⠀⢀⠀⠔⠆⠁⠈⠠⠀⡹⡏<br>⡖⣠⠄⠀⠯⢜⢨⠊⣒⢡⠨⡀⠢⢭⠴⡊⢕⠐⣄⡓⡾⠋⠗⠉⢀⠚⠀⢃⠂⠥⠲⠀⠀⠀⠄⠐⠀⠀⠐⠀⠁⠄⠱⠁⠊⠈⡀⠀⠊⣽<br>⠀⡉⠒⣃⠰⡀⢁⠘⡉⠪⠋⡲⡅⠍⡎⡪⢣⠽⢭⠍⡥⠁⠂⡰⠠⣄⠥⠐⠀⠣⠄⢀⠐⠁⡀⠀⢐⠐⠀⠠⠁⠂⠄⠠⠀⠁⡀⠐⣫⡟<br>⠐⢔⠁⠀⠬⠑⠗⠴⠀⠢⡁⢌⠅⢘⠓⡛⠈⡀⠄⠆⠠⠠⠢⢂⠕⠷⠈⢀⠈⡒⠄⠂⠀⠀⠈⠀⡀⠡⠈⠀⠆⡐⠀⠀⠓⠀⠀⠀⢐⢼<br>⡀⠀⠈⠐⠠⠀⠀⠁⠁⠣⢀⡁⡄⠂⠔⠂⠂⢉⠁⡌⠄⠜⠈⠡⠐⠀⡐⠀⢨⠀⠁⠀⠀⡀⠍⠄⠠⠁⠀⠠⢄⠈⠀⠀⡄⠀⠀⡀⠒⣸<br>⢘⠉⡒⠤⠌⢀⠑⠕⠀⠄⠄⠄⠀⠄⠑⠉⠨⠀⠄⠀⠂⠃⠀⠀⠈⠄⠄⠠⠈⠀⠀⡀⠠⠁⢠⠁⠁⠀⠐⠱⠀⠀⠀⡐⠀⠉⠄⠀⢸⠾<br>⠀⠘⠈⡀⠈⠀⠈⠨⠐⠠⠠⠐⡀⡄⢠⠀⢀⠨⠀⠃⠀⠀⡁⡠⠀⠩⠀⠂⠁⠀⠀⠀⢒⡄⠊⠀⠀⢀⠈⠁⠀⠀⠀⠆⠘⠁⠄⠀⠄⣿<br>⠄⡄⠀⠈⠠⠀⡀⠀⠀⠄⠀⠂⠀⠀⠄⠀⢀⠁⠁⢁⠁⠆⠀⠀⠀⠀⡀⠀⠈⠀⡀⠀⠱⠀⠀⠀⠀⠂⢄⠈⠀⠀⡀⡨⠠⡀⠠⠀⠄⡼<br>⠠⠀⠁⠊⢀⠀⠠⠁⠁⠂⠂⡄⢄⠐⡀⢀⠊⠂⡀⡁⡀⢀⢀⠠⠀⠄⠂⠡⠠⠁⠀⠀⠀⠂⠀⢠⠒⠀⠀⠀⠐⠢⠀⢀⠀⠀⠄⠄⣿⣿<br>⠁⠋⠙⠊⠐⠕⠁⡂⠈⠅⠠⠈⠐⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠀⠉⠀⠐⠀⠀⠀⠀⠀⣈⠀⠀⠀⠀⠈⡂⠈⠀⠀⠘⠌⢀⠥<br>⠀⠀⠀⠀⠔⠔⠀⡀⡉⠀⠀⠀⠂⠠⠠⠀⠄⠄⠀⣀⢀⠀⡈⠀⠌⡐⠈⠈⠀⠀⠀⠀⠅⠀⣐⠉⠄⠀⠀⣂⠠⠁⡈⠀⠄⠄⢀⠣⢶⢿<br>⠄⠀⠀⡁⠀⠄⠀⠀⠁⠈⠀⠈⠀⠁⠀⠁⡀⠁⠀⠁⠀⠀⠀⡀⠀⠀⠀⠀⠀⠠⡀⠑⠀⠀⠎⠀⢬⢠⠀⢂⠠⠢⠠⠈⡐⠸⠀⡐⣹⢷<br>⠩⠥⠂⠆⡆⢠⠀⢄⠀⣀⡀⣄⠀⢈⠀⠀⣀⡀⡀⡀⠄⡄⠡⠀⠐⠀⠑⠀⠀⠁⠒⠒⠉⠡⡀⠈⠈⢀⠥⠈⠀⠀⠀⠀⠈⣞⣏⣿⡏⣿<br>⠾⠝⠷⢿⣯⣿⠧⡧⠭⠣⠭⡭⡮⢭⠶⠶⠶⠦⣗⡶⠽⠭⣿⣶⠷⠵⠮⠽⠿⠮⠿⢷⡶⣖⡷⠲⠞⠷⠾⢿⢷⣿⣿⣿⣿⣯⢇⠟⡧⢈
pipes
clean data flow without nesting
things flow from top to bottom
"hello!!"<br>|> string.upper<br>|> string.sub(0, 4)<br>|> fn(s) s + ", world!"<br>|> inspect
# or with placeholders,<br>"hello!!"<br>|> _:upper() # obj:method() == obj.method(obj)<br>|> _:sub(0, 4)<br>|> do<br># you can even put any expression here<br># even do-end blocks<br>_ + ", world!"<br>end<br>|> print
# this is the same, but look at the order of operations<br>print(log("hello":upper():sub(0, 4) + ", world!"))
errors-as-values
nil and booleans are replaced by atoms
you can’t use a value without handling an error
all crashes are explicit (WIP)
aided massively by pattern matching, ?, orelse, and :unwrap()
# f might be<br># (:ok, "file-contents")<br># or (:err, :IoError)<br>const f = fs.open({path = "./readme.md"})
# `?` unwraps :ok and panics on :err at top-level<br>const f2 = fs.open({path = "./readme.md"})?
# crashes if :err<br>const f = fs.open({path = "./readme.md"}):unwrap()
everything is an expression
no statements, everything (really) always returns a value
…but the code still looks procedural
let x = 10 # this line evaluates to 10<br>let label = if x > 0 "positive" else "zero"<br>let a = let b = 5 # this whole line evaluates to 5
fn is_true() 5 + 5 == 10<br># both x and is_true are the same function<br>const x = fn is_true() do # do-end is one too<br># return and break are special<br>return 5 + 5 == 10<br>end
comp
execute any (really) expression at compile time
any script can be compiled into bytecode and get any value baked in
revo -b script.rv<br>revo script.rvo
the compile-time VM does not differ from the runtime one
# asks for a ling of input at build-time<br># then keeps the result at run-time<br>const x = comp read()
const long = do<br>let t = 0<br>for x in 0..100<br>t += x<br>t # similar to rust's {},<br># revo do-end blocks return the last value<br>end
procedural macros
along with an AST-substituting macro system,
this lets you just get an iterator over the raw ast tokens, run any code to transform them
, then return back a table of the new ast
# > num, num, num -> Sigma^4_n=1(a * b + c)<br>proc cmul!(iter) do<br>print("inner: ", add3!(10,20,12))<br>print("peek: ", iter:peek())<br>match iter:peek()<br>| (:number, n) => print("is number", n)<br>| (other, n) => print(other, n)<br>| x => print("not tuple: ", x)
let a = 10 + (iter:next_of(:number))<br>let b = iter:next_of(:number)<br>let c = iter:next_of(:number)
let acc = 0<br>for i in 1..5 do<br>acc += a * b + c<br>end
{(:number, acc)}<br>end
print(cmul!(10,20,30))
pattern matching
destructure and branch in place
you will be using atoms and tuples, they are beautiful solutions to their problems
match (:ok, 42)<br>| (:ok, v) => v<br>| (:err, e) => panic(e)<br>| _ => panic()<br>| _ => panic()<br># _ is wildcard, when nothing else matched<br># if you want to grab the actual value<br># , just put any binding name there
const response = match "hello!"<br>| "hello!" => "hi!"<br>| x when (x:len() > 10) => ""<br>| x when string?(x) => x + " to you too!"<br>| _ => ":("
let f = match read({path = "./readme.md"})<br>| (:ok, file) => file<br>| (:err, error) when error == :FileDNE<br>=> panic("file does not exist")<br>| (error) => panic("error")<br>| x => panic("unknown: ", x)
fibers
i made all your blocking code become non-blocking by just adding a spawn before it
fn serve(peer, message) do<br>peer:send(message)?<br>end
while :true do<br># accept the next connection; if none is ready, this fiber parks until the<br># runtime sees a connection on the listening socket.<br>let conn = server:accept()?<br># the only thing you have to do to make it async is to add `spawn`...