Skip to content

Instantly share code, notes, and snippets.

@lukewagner
lukewagner / sketch.wat
Last active July 10, 2025 19:25
canon log maybe??
(component
(canon log (level info) (num-strings 2) (core func $basic-log))
(canon log (level warn) (num-strings 2) (format 1 "at {0} I thought {1}") (core func $formatted-warning))
(core module $M
(import "" "basic-log" (func $basic-log (param $str1-ptr i32) (param $str1-len i32)
(param $str2-ptr i32) (param $str2-len i32))
(import "" "formatted-warning" (func $fancy-log (param $str1-ptr i32) (param $str1-len i32)
(param $str2.1-ptr i32) (param $str2.1-len i32)
(param $str2.2-ptr i32) (param $str2.2-len i32))
...
package postgres:api {
interface connection {
query: func(...) -> ...;
execute: func(...) -> ...;
}
interface connections {
*: connection;
}
interface runtime-connections {
resource connection = resourceify(connection);
;; Each of these 4 modules is independently published. Note that, while there is a non-trivial amount of type-y
;; boilerplate, it is proportional in size to only the *direct* dependencies.
(module $A
(type $Wasi (instance ...))
(import "wasi" (instance (type $Wasi)))
(func (export "a") ...)
)
(module $B
@lukewagner
lukewagner / ArrayBuffer.transfer
Created November 13, 2014 23:38
ArrayBuffer.transfer strawman
Proposal
--------
The proposal is to add a static ArrayBuffer.transfer(oldBuffer [, newByteLength]). This
method returns a new ArrayBuffer whose contents are taken from oldBuffer.[[ArrayBufferData]]
and then either truncated or zero-extended to be newByteLength. This operation leaves
oldBuffer in a detached state. If newByteLength is undefined, oldBuffer.byteLength is
used.
var buf1 = new ArrayBuffer(40);