Folkert de Vries
a fast, friendly, functional language
x + 1
C
1 instruction
Python
>> 1 instruction
allocation
bookkeeping
representation
roc applications run on a platform
a "domain-specific runtime"
shape of main
IO primitives
(de)allocation
malloc
free
a surprisingly OK solution for short-lived applications
a webserver for roc that does not malloc/free
make memory allocation flexible
without bothering most users
problem: when is the application done with memory?
drop-specialized
beans
perceus
rc
your actual data
m = "Hello Delft!" # rc == 1
# inc m 2 # rc == 3
t = (m , m) # rc == 3
# ~ t gets used ~
# dec m # rc == 2
# dec t.0 # rc == 1
# dec t.1 # rc == 0
# free t.1
RC cannot break cycles
List.reverse = \list ->
if refcount list == 1 then
#reverseInPlace list
else
#reverseInPlace (List.clone list)
f : (I64 -> I64) -> I64
f = \p -> p 12
main =
y = 42
g = \x -> x + y
f g
how do we turn this into C?
f : (I64 -[ G { y: I64 } ]-> I64) -> I64
f = \p -> p 12
main =
y = 42
g = \x -> x + y
f g
f : (I64 -[ G { y: I64 } ]-> I64) -> I64
f = \p -> p 12
g = \x, { y } -> x + y
main =
y = 42
f ???
f : [ G { y: I64 } ] -> I64
f = \G c -> g 12 c
g = \x, { y } -> x + y
main =
y = 42
f (G { y })
f : [ G { y : I64 }, H {} ] -> I64
f = \closure ->
when closure is
G c -> g 12 c
H c -> h 12 c
g = \x, { y } -> x + y
h = \x, {} -> x + 1
main =
y = 42
f (if a == b then G { y } else H {})
Simplified inference of lambda sets
(session at POPL 2024)
RC borrow inference for List/Str
allocation
bookkeeping
representation
a fast, friendly, functional language