{"id":"type--buffer-of-T-a3fe58","name":"buffer of T","owner":"yeho","package":"language.types","kind":"type","signature":"buffer of T","description":"Contiguous typed storage for data processing, including explicit compute input and output.","context":"A focused reference with a complete example. Numeric widths and experimental types still depend on the selected backend.","parameters":[],"returns":"","members":[],"tags":["compute","containers-and-handles","cpu","gameplay","gpu","type","yeho"],"updated":"2026-09-09","source":{"repository":"demonhunterlabs","path":"app/lib/yeho-language-reference.ts"},"status":"documented","notes":[],"examples":[{"id":"cpu","title":"CPU · [cpu]","description":"Apply damage to a small batch of health values on the explicit CPU route. Each invocation owns one element.","code":"[cpu]\ncompute ApplyDamage(buffer of int health, int damage)\n{\n    int index = compute.index\n    if index >= health.count { return }\n    health[index] = health[index] - damage\n}\n\nbuffer of int health\nhealth.Add(100)\nhealth.Add(80)\nhealth.Add(60)\ncomputeTask job = dispatch ApplyDamage(health, 10)\nwait job\nif job.failed { Console.Error(job.error.message) Process.Exit(1) }\nfor index from 0 < health.count { Console.Log(Text.From(health[index])) }\n","tags":["cpu","compute","gameplay"],"run":"cpu-oracle","expected":"90\n70\n50","verifyRun":false,"manifest":"manifestVersion = \"2\"\npackage = \"api.example.language__buffers\"\nversion = \"0.1.0\"\nlanguageEdition = \"yeho-core-2026.1\"\n\n[app]\nkind = \"headless\"\n","verification":"type checked","sha256":"49ff2585eb7d092d68b446d7eb7224644c0fb1636822dcf89521faf7707eaeaa","checked":"2026-09-09","diagnostic":"","observedOutput":null,"checkedBackend":null},{"id":"gpu","title":"GPU · [gpu]","description":"Double a batch of reward values on native Metal. The [gpu] tag requires an accelerator backend; CPU oracle cannot silently satisfy it.","code":"[gpu]\ncompute DoubleRewards(buffer of int rewards, int multiplier)\n{\n    int index = compute.index\n    if index >= rewards.count { return }\n    rewards[index] = rewards[index] * multiplier\n}\n\nbuffer of int rewards\nrewards.Add(100)\nrewards.Add(80)\nrewards.Add(60)\ncomputeTask job = dispatch DoubleRewards(rewards, 2)\nwait job\nif job.failed { Console.Error(job.error.message) Process.Exit(1) }\nfor index from 0 < rewards.count { Console.Log(Text.From(rewards[index])) }\n","tags":["gpu","compute","gameplay"],"run":"metal","expected":"200\n160\n120","verifyRun":false,"manifest":"manifestVersion = \"2\"\npackage = \"api.example.language__buffers\"\nversion = \"0.1.0\"\nlanguageEdition = \"yeho-core-2026.1\"\n\n[app]\nkind = \"headless\"\n","verification":"type checked","sha256":"8b68476c6e65ff66879e53f7560b7cc51cfabff2e02ca5f88202423872b62292","checked":"2026-09-09","diagnostic":"","observedOutput":null,"checkedBackend":null}],"searchTerms":[],"url":"https://demonhunterlabs.com/academy/api?item=type--buffer-of-T-a3fe58","json":"https://demonhunterlabs.com/reference/items/type--buffer-of-T-a3fe58.json","markdown":"https://demonhunterlabs.com/reference/text/type--buffer-of-T-a3fe58.md"}
