Files
rexlang/examples/03_shared_app.rex
Your NameandClaude Opus 5.5 7cf9727bcd Rename the language from Dino to Rex
Files use .rex, the command is rex, and the crate, runtime prefixes,
docs, editor files and examples all use the new name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:51:23 +01:00

33 lines
707 B
Rexx

// A desktop-style app: shared state, weak back-references, tasks.
import ui
import task
struct Document {
title: string
text: string
}
struct Editor {
doc: shared Document // many views can share one document
parent: weak Window? // weak: no ownership cycle
}
func main() {
var doc = shared Document{title: "Notes", text: ""}
var win = ui.window("Rex Notes", 640, 480)
var editor = Editor{doc: doc}
win.on_key(func(k: ui.Key) {
editor.doc.text += k.char
})
var ch = task.channel[string]()
task.spawn(func() { // background autosave
for text in ch.recv() { save(text) }
})
win.on_close(func() { ch.send(doc.text) })
win.run()
}