示例工程 01-mental-model

01-mental-model/01-hello-chunk/README.md

markdown · 0.5 KB

# 01 · hello-chunk
 
**演示**:最小 chunk:没有 `main`、没有入口函数,顶层语句就是全部。
**运行时**:`lua54`、`luajit`。
**运行**:
 
```sh
.tools/bin/lua54 scripts/run-example.lua examples/01-mental-model/01-hello-chunk
.tools/bin/lua54 scripts/test-example.lua examples/01-mental-model/01-hello-chunk
```
 
**预期输出**(lua 5.4.9 / macOS arm64):
 
```text
hello from chunk
```
 
**看点**:`if not ... then` 区分「被当脚本运行」与「被 `require`」。
**注意**:`require` 时顶层不产生输出。