示例工程 01-mental-model
01-mental-model/04-require-vs-dofile/README.md
# 04 · require-vs-dofile
**演示**:`require` 把结果放进 `package.loaded` 并复用;`dofile` 每次都重新执行,得到新表。
**运行时**:`lua54`、`luajit`。
**运行**:
```sh
.tools/bin/lua54 scripts/run-example.lua examples/01-mental-model/04-require-vs-dofile
.tools/bin/lua54 scripts/test-example.lua examples/01-mental-model/04-require-vs-dofile
```
**预期输出**(lua 5.4.9 / macOS arm64):
```text
require_same=true
dofile_same=false
```
**看点**:模块缓存是「模块名 → 返回值」,不是文件内容缓存。
**注意**:本例故意使用 `dofile` 做对照,其它示例不建议用它。