stack lang
a little bit of forth, python & lisp
1 + 1
is
(1 + 1)
to
1 1 +
or
a = 10
to
10 a !
special case for infix assignment
a = 5
to
5 a !
instead of
a 5 =
steal type checking from WASM
https://binji.github.io/posts/webassembly-type-checking/
struct ball
x float
y float
var my-ball = ball(0, 0)
puts my-ball.x
set a 10
set set
:= let
= equals or ==
mem = bytearray(0x8000)
Review how Uxa does this
stack functions
push
pop
peek
print
get
object is a union, it can be a list or a void*
struct list {
struct object *elem;
struct object *next;
}
struct object {
int tag;
union {
void *vs;
} u;
}
version 0
puts <<end
hello,
How are you doing today?
bye!
end
so I can write reverse polish notation as a statement
emit 42
rpn 42 emit
head, *tail = "one two three"
into
['one', ['two', 'three']]
(1 + 2 + 3)
into
['+', ['1', '2', '3']]
puts (9 + 11)
into
['puts', [['+', ['9', '11']]]]
double(10)
into
[double [infix [10]]]
puts double(10)
into
[puts [[double [infix [10]]]]]
def double
dup
$ + $
into
( def double \n
( dup \n )
( $ + $ \n ) )
fn main {
puts "hello"
}
into
( fn main { \n
( puts "hello" \n )
} \n )
- server exe
- listen on tcp
- linked list of functions
- linked list of variables
- define new functions
- redefine functions
- call function
- list functions
- inspect global state
functions include both source code and compiled versions