a LISP programming language for high performance and extremely concise web assembly modules
clojure
; main.w
(extern console_log [message])
(defn main "main" []
(console_log "Hello World!")
nop
)
console
wasp build
When necessary, low level web assembly can be directly inlined ```clojure (defn-wasm malloc "malloc" [i32] [i32] ; export as "malloc", 1 input, 1 output ; this function creates an ever increasing memory allocation ; it writes the length in the first 4 bytes of the block ; followed by an zero byte to represent its free ; followed by the content [i32] ; 1 local variable to represent let currentheap = 0 ; currentheap = global.heap GLOBALGET 1 LOCALSET 1 ; memory[currentheap..currentheap+3] = length GLOBALGET 0 LOCALGET 0 I32STORE 0 0 ; global.heap = currentheap + 5 + length LOCALGET 1 I32CONST 5 I32ADD LOCALGET 0 I32ADD GLOBALSET 1 ; return currentheap + 5 LOCALGET 1 I32CONST 5 I32ADD END )
(defn main "main" [size] (malloc size) ) ```
true
is 1, false
is 0nop
implies the function does not return a value