mirror of
https://github.com/luau-lang/rfcs.git
synced 2025-05-04 10:43:48 +01:00
Initial commit
This commit is contained in:
parent
e609f9c084
commit
3bcd3f0383
1 changed files with 35 additions and 0 deletions
35
docs/require-by-string-glob-imports.md
Normal file
35
docs/require-by-string-glob-imports.md
Normal file
|
@ -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?
|
Loading…
Add table
Reference in a new issue