커밋 d894fc0의 AUTHORING.md를 그대로 옮긴 것으로, 본문은 아직 영어입니다. 패키지는 0.1.0에서 쓸 typeshade라는 이름으로 가져옵니다.
빠른 참조
| Need | Write |
|---|---|
| A function | fn — return type inferred |
| An entry point | fn(name, { vid: builtin('vertex_index', u32T) }, body, { stage: 'vertex' }) |
| A module | module({ consts, structs, bindings, funcs }) |
| An intermediate value | plain const x = expr |
| Mutate it | x.assign(v) (auto-materialises a var) |
| A literal in an op | bare number — x.add(1), vec4(p, 0, 1) |
| deg↔rad | radians(x) / degrees(x) |
| Branch (statement) | If(c, …).elif(c, …).else(…) |
| Branch (value) | when(c, ()=>a, ()=>b) / when([[c,()=>a]], ()=>b) (was ifExpr/condExpr) |
| Exhaustive integer dispatch | enumU32({A:0,B:1}) + matchEnum(s, E, { A:()=>…, B:()=>… }) (missing arm = compile error) |
| Integer dispatch | Switch(s).case(n, …).default(…) |
| Loop fold (value) | reduce(init, i0, cond, (acc,i)=>…, step) |
| Early return | Return(v) / ReturnIf(c, v) |
| IO struct | ioStruct(name, { f: builtin(...)/location(...) }) → .of(n).f, .construct({…}), .type, .decl |
| Uniform | uniformStruct(name, at, fields) → .field.f, .struct, .binding |
| Storage element struct | structDecl(name, fields) → .of(n).f, .type, .decl |
| Storage buffer | storageBuffer(name, Element, at) → buf.at(i).f |
| Texture / sampler | resource(name, type, at) → .node, .binding |
| A shared const | import the handle (PI, EARTH_R) — not constRef('NAME') |
| A hand-written (raw) statement | rawStmt({ wgsl, glsl }) / b.raw(…) — verbatim per target; a missing side fails closed on that backend |
| Double precision | declare values as f64T — same operators; toF64/toF32 to convert; write 1.0 to the auto _fp64 |
| A non-scalar const | constExpr(name, type, valueNode) — vec4 / arrayLit / struct literal |
| Call a function | import the FnHandle, call directly — not callFn('name') |
| Diagnose a module | diagnose(m, { backend }) → formatReport(report) (lint + caps, no throw) |
| Need a GPU extension/feature | module({ enables: ['floatRenderTarget'] }) — host activates from reflect().requiredFeatures |
| Source locations in errors | setSourceTracing(true) (dev-only, off by default, never on emit) |