Q+ STD API(核心模块,1.12.0-dev 文档预览;实现基线 1.11.0-dev/v4.42)
English summary. Standard-library core-module API coverage (new): 269 public functions extracted from 9 modules (
math/string/array/fs/net/async/io/u64/fmt) with signatures/returns/limits; 30+ sampled VM calls and error/edge cases recorded; known behavior discrepancies documented (e.g.str_chars("héllo")returns 4). Not a complete API reference (hundreds of extension modules*_ext.qetc. not covered) and not a stability/API-1.0 promise. Full tables: 中文 STD_API · English summary.
Q+ 标准库核心模块公开 API(从 stdlib/std/*.q 源码提取,抽样 VM 实测)。状态: 1.12.0-dev 文档预览(spec v4.43 TBD;NOT PUBLISHED);源码为权威,本页为覆盖文档,不是完整 API 参考/稳定性承诺。
覆盖(269 个公开函数 / 9 模块)
| 模块 | 源码 | 公开函数 | VM | AOT | 关键限制 |
|---|---|---|---|---|---|
std.math | stdlib/std/math.q | 47 | ✓ | 可用 | 纯 Q+ f64 级数实现,6 位小数精度(非 libm 位级) |
std.string | stdlib/std/string.q | 47 | ✓ | 可用 | 字节语义;str_chars 简化计数(非真码点) |
std.array | stdlib/std/array.q | 44 | ✓ | 可用 | i32 元素;越界 array_get 返回 0(非 loud) |
std.fs | stdlib/std/fs.q | 21 | ✓ | loud | VM-only;无递归删除/chmod/symlink/路径规范化 |
std.net | stdlib/std/net.q | 49 | ✓ | 部分(AOT_NET_POC TCP loopback) | VM-only loopback POC;无 DNS/TLS/公网/生产 |
std.async | stdlib/std/async.q | 10 | ✓ | loud | VM-only stackful 任务;AOT trap |
std.io | stdlib/std/io.q | 32 | ✓ | 基础可用 | sys_svc 路径 AOT 门控;exec_capture 桩 |
std.u64 | stdlib/std/u64.q | 13 | ✓ | loud(u64 程序) | AOT u64 loud;常量池 3072 |
std.fmt | stdlib/std/fmt.q | 6 | ✓ | 可用 | 纯 Q+ 包装 |
公开函数 = 顶层
fn;排除_内部前缀、sys_*syscall 薄封装、net_sim_*/dns_*/stream_*测试支持层。 269 个中 192 个在源码注释中有直接说明。
抽样实测(VM,v200_rc1 工具链真实输出)
math.sqrt(9)=3.000000 · math.pow(2,10)=1024.000006 · str_len("héllo")=6 · str_chars("héllo")=4(注释称码点=5,已知差异) · str_substr("abcdef",1,3)="bcd" · array_fill/len/sum/get → 4/28/7 · u64.wrapping_add(max,1)=0 · u64.checked_add(max,1).ok=0 · u64.saturating_add(max,1)=max · u64.parse_u64(2^64).ok=0 · fmt_int(42)="42" · write_file/read_file → true/"vmio" · fs_mkdir/fs_file_type/fs_type_name → true/2/"dir" · async.spawn+task_wait → 7 · net_epoll_create/close → 0/0 · net_tcp_socket()(无 QPLUS_NET_REAL)→ -8 · net_tcp_close(-1) → -4 · fs_readdir_count("no_such") → -1 · str_to_u64("oops") → rc=1 runtime assert abort。
已知差异/限制
str_chars:注释写 UTF-8 码点数,实测只计可打印 ASCII/空白 →str_chars("héllo")=4(期望 5);需真码点请等待修复/自行处理。math.pow(2,10)=1024.000006(6 位打印/浮点近似);数学精度 ~5e-7,非 libm 位级。array_get越界返回 0(非 loud);str_substr越界静默截断/空串;str_to_int前缀解析("12x"→12)。- 网络默认仿真 loopback;真 loopback 需
QPLUS_NET_REAL=1,非 loopback 需显式权限;否则net_tcp_socket()实测 -8。 - fs/async VM-only(AOT loud);u64 AOT 程序 loud;io
sys_svcAOT 门控;AOT 网络仅 AOT_NET_POC TCP loopback 子集。 - 覆盖范围:仅核心 9 模块;
*_ext.q等扩展模块未收录;不宣称完整 API 参考/稳定 API。
相关
AOT 网络 v2(std.net TCP/UDP 子集) · 网络 Phase6 · STD_API_NET · OS SDK 1.10 · SBOM 签名 POC · Playground 文档 · Windows/Wine 指南
快速上手 · 语言指南 (EN) · 规范摘要 (EN) · 中文 STD_API · English STD API summary · 网络 Phase5 · AOT 网络 POC · SBOM · 英文摘要索引