Clarify motivations

This commit is contained in:
ffrostfall 2025-02-10 22:30:04 -05:00
parent 3bcd3f0383
commit 321c18cdda

View file

@ -2,19 +2,28 @@
## 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
- Many patterns utilize current dynamic requires, or load in luau files manually:
- ECS systems
- The "service" pattern
- Module initializers
- Tests
- The alternative (writing out manual requires) is quite cumbersome and not feasible to expect developers to do
- Cross-runtime/platform automated testing is currently impossible
- Current dynamic requires are not type safe and can have cyclical dependency errors which are not picked up on. This isn't a conceptual limitation, it is totally possible to report.
- Cross-module compilation may be wanted in the eventual future. But this pattern is common and will not be going away. There should be a way to express "requiring all children of a directory" while still having full cross-module compilation.
## Design
- directory/\*\* for descendants
- directory/\* for children
- Alphanumeric ordering
- Alphanumeric ordering off file name
- file1
- file12
- file13
- file2
- file31
- file3
- "File name" does not include extension!
```lua
local children = require("directory/*)") -- array