빠른 참조

커밋 d894fc0의 AUTHORING.md를 그대로 옮긴 것으로, 본문은 아직 영어입니다. 패키지는 0.1.0에서 쓸 typeshade라는 이름으로 가져옵니다.

빠른 참조

NeedWrite
A functionfn — return type inferred
An entry pointfn(name, { vid: builtin('vertex_index', u32T) }, body, { stage: 'vertex' })
A modulemodule({ consts, structs, bindings, funcs })
An intermediate valueplain const x = expr
Mutate itx.assign(v) (auto-materialises a var)
A literal in an opbare number — x.add(1), vec4(p, 0, 1)
deg↔radradians(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 dispatchenumU32({A:0,B:1}) + matchEnum(s, E, { A:()=>…, B:()=>… }) (missing arm = compile error)
Integer dispatchSwitch(s).case(n, …).default(…)
Loop fold (value)reduce(init, i0, cond, (acc,i)=>…, step)
Early returnReturn(v) / ReturnIf(c, v)
IO structioStruct(name, { f: builtin(...)/location(...) }).of(n).f, .construct({…}), .type, .decl
UniformuniformStruct(name, at, fields).field.f, .struct, .binding
Storage element structstructDecl(name, fields).of(n).f, .type, .decl
Storage bufferstorageBuffer(name, Element, at)buf.at(i).f
Texture / samplerresource(name, type, at).node, .binding
A shared constimport the handle (PI, EARTH_R) — not constRef('NAME')
A hand-written (raw) statementrawStmt({ wgsl, glsl }) / b.raw(…) — verbatim per target; a missing side fails closed on that backend
Double precisiondeclare values as f64T — same operators; toF64/toF32 to convert; write 1.0 to the auto _fp64
A non-scalar constconstExpr(name, type, valueNode)vec4 / arrayLit / struct literal
Call a functionimport the FnHandle, call directly — not callFn('name')
Diagnose a modulediagnose(m, { backend })formatReport(report) (lint + caps, no throw)
Need a GPU extension/featuremodule({ enables: ['floatRenderTarget'] }) — host activates from reflect().requiredFeatures
Source locations in errorssetSourceTracing(true) (dev-only, off by default, never on emit)

이 페이지 편집