glimt
glimt is what runs inside a page in
utsikt. a page asks for it
with <script type="text/x-glimt">, which makes its
scripts and its onclick attributes glimt. the language
is a small part of c0, so
anyone who has written a moonshot program can already write one. the
browser turns it into x86-64 machine code the first time it runs.
int clicks = 0;
void bump() {
clicks += 1;
set_text(by_id("count"), concat("clicked ", num(clicks)));
}
with that in a page, an element with onclick="bump();"
counts its own clicks. every value is an int. there are functions, if
and else, while and for with break and continue, return, and c0's
operators. a page's scripts run top to bottom once when it loads, before
its first frame.
what a page can reach
a script reaches the page through ten builtins and nothing else. it can
find an element by its id, read and replace its text, change its class
and read a few of its attributes. strings are built with
num, concat, len and
eq. elements and strings are handles, small numbers that
index a table the page owns, not pointers, so a script cannot write
anywhere in utsikt's memory.
the code glimt writes never faults. division by zero gives 0, a loop that runs too long or a function that runs out of stack is stopped with a line in the serial log, and the next script on the page runs as if nothing happened.