Q+ 语言指南(进阶篇:错误/类型/并发/网络/AOT)
English summary. Advanced language guide for Q+ 1.13.0-dev / spec v4.44 (candidate, NOT PUBLISHED): five practical chapters with real v230 toolchain commands/outputs — error model (TC codes/exit codes, runtime
Runtime error:rc=1, AOT loud/errno-style network codes), type-system boundaries (u64 full literals incl. binary, negative-u64 loud, generic erasure/no bounds, float printing and the AOT float-comparison residual: same program givesVM: neg-lt-ok half-lt-ok gt-okvsAOT: neg-lt-bad half-lt-bad gt-bad— no overall AOT float parity claim), concurrency (VM stackful async tasks/ucontext; threads/channels/pools; cooperative; AOT async traps loudly), network (VM Phase1–6 loopback POCs; AOT TCP+UDP loopback subset with Phase3/4 timeout/nonblock/poll; opt-inQPLUS_NET_REAL=1; no DNS/TLS/ public network; errno table), and AOT/VM differences (fd opaque vs raw OS fd, floats, strings, support scope, loud unsupported paths). Full Chinese guide: docs/LANGUAGE_GUIDE.html · English summary: docs/LANGUAGE_GUIDE.en.html.
章节(每章附实测命令/输出)
- 错误模型:编译期 TC + 退出码;运行期
Runtime error:rc=1(无异常);AOT 支持路径 同文案、未支持能力 loud、网络 errno 风格错误码。 - 类型系统边界:小整数 checked;u64 字面量全域(十进制/hex/二进制 ≤2^64-1、负 u64 loud、 常量池 3072);泛型擦除/无 bounds/dyn loud;浮点打印与 AOT 浮点比较残差。
- 并发:async stackful 任务(ucontext,合作式)、threads/channels/pools(消息传递)、 VM-only;AOT 构建后运行到任务原语 loud trap;Windows Fibers 为子集(PASS=27/0/2, 非平台可用)。
- 网络:VM Phase1–6 loopback POC;AOT TCP+UDP loopback 子集(opt-in,native 200–208/210–214/215–217;nonblock/poll/async -8);错误码表(-2/-4/-7/-8/-9/-10/-13)。
- AOT vs VM 差异表:平台、fd、浮点、字符串、支持范围、限制、错误、常量。
关键实测(v230 工具链,Linux x86-64)
tc_str.q → [TC1] want=i32 got=string (rc=4)
tc_mix.q → [TC9] want=u64 got=i64 (rc=4)
tc_u64neg.q → [TC15] integer literal out of range (rc=4)
div0.q → Runtime error: division_by_zero: division by zero (rc=1)
oob.q → Runtime error: index_out_of_bounds ... (rc=1)
u8over.q → Runtime error: overflow: integer overflow (rc=1)
u64full.q → 18446744073709551615 17361641481138401520
floatcmp.q → VM 0.300000 ne
floatneg.q → VM: neg-lt-ok half-lt-ok gt-ok 0.250000
AOT: neg-lt-bad half-lt-bad gt-bad 0.250000 ← AOT 浮点比较残差
async_task.q → task start / task done / 11
async_task AOT → Runtime error: runtime_error: AOT: async primitives unsupported (VM-only)
thread_join.q → 42
netcodes.q → -4 -8
tools/test_float_parity.sh → FLOAT_PARITY_PASS
tools/test_net_poc6.sh → NET_POC6_PASS ... (UDP_QUEUE_OK 64 1 63)
tools/test_net_aot.sh → NET_AOT_PASS(AOT_NET_STD_OK / UDP_OK / UDP_TIMEOUT -2 / UDP_NB -13 / ACCEPT_TIMEOUT -10)
tools/test_net_aot_p4.sh → AOT_NET_PHASE4_PASS(AOT_NET_TCP_NB_OK -13 -13 -10 / AOT_NET_POLL_OK 1 1)
完整可运行示例、错误码表与边界见中文指南与英文摘要: docs/LANGUAGE_GUIDE.html · docs/LANGUAGE_GUIDE.en.html。
不得宣称(边界)
- 不宣称 AOT 浮点整体 parity:仅 pow 修复范围一致;通用浮点比较对 f64 残差存在 (实测 VM/AOT 输出不同);依赖浮点比较请用 VM 或显式整数路径。
- 不宣称完整网络/生产可用:VM 网络为 Phase1–6 loopback POC;AOT 网络仅 Linux x86-64 阻塞 IPv4 loopback TCP+UDP 子集(opt-in;nonblock/poll/epoll/async -8);无 DNS/TLS/ 公网/异步;Windows/ARM64 -8。
- 不宣称 Windows 平台可用:Windows 仅 VM/async Fiber 子集(wine PASS=27/0/2;非真实 Windows/MSVC;无 AOT)。
- AOT 非 VM 完整替代;AOT 多模块仅 POC;A5 非无条件 full-u64;1.13.0-dev 为发布候选 (NOT PUBLISHED)。
相关
语言规范(中文权威) · 英文规范摘要 · 快速上手 · STD API · FLOAT_PARITY · AOT_NET_POC · NET_IMPLEMENTATION_PHASE6 · English 摘要索引