From 3bcd3f0383c8dacd3a6f2c1b8f9b47a7a9479706 Mon Sep 17 00:00:00 2001 From: ffrostfall <80861876+ffrostfall@users.noreply.github.com> Date: Mon, 10 Feb 2025 22:23:15 -0500 Subject: [PATCH] Initial commit --- docs/require-by-string-glob-imports.md | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 docs/require-by-string-glob-imports.md diff --git a/docs/require-by-string-glob-imports.md b/docs/require-by-string-glob-imports.md new file mode 100644 index 0000000..6c67fd9 --- /dev/null +++ b/docs/require-by-string-glob-imports.md @@ -0,0 +1,35 @@ +# Glob import syntax for require-by-string + +## Motivation + +- Cross-runtime automated testing +- Auto-requiring ecs systems +- Commands for things like discord bots +- Module loaders in general +- Type safety (even if it's typed to be unknown, it's better than typecasting to any.) +- Cyclical dependency reporting +- This would be required for static cross-compilation or whatever the term is + +## Design + +- directory/\*\* for descendants +- directory/\* for children +- Alphanumeric ordering + +```lua +local children = require("directory/*)") -- array +local descendants = require("directory/**") -- array +``` + +## Alternatives + +- Provide a dictionary where { [name]: return value }? + - In descendants, this might cause duplicates. + - Include file extension? Can have duplicates if no file extension. + +## Drawbacks + +- Cross-runtime ordering? +- OS causes implementation concerns? +- Type concerns? +- Might promote bad patterns?