[Feature] Enable import of pure functions in circular dependency import
- Lenguaje dominante
- Rust
- Estrellas
- 5.2k
- Forks
- 145
- Merge medio
- 5 d 3 h
- PR fusionados (30 d)
- 7
Descripción
**Is your feature request related to a problem? Please describe.**
This problem enables the import of pure functions even if there is an import dependency cycle. This issue implements a logic that works under the hood and has no impact on syntax.
- If all imported functions are pure, then import is pure. This means that we can import pure functions from file that normally would create a dependency cycle.
- Pure import is separated from regular import in `import_cache`.
- Pure functions are placed before all the generated bash code.
- Pure functions are the ones that don't depend on external variables nor functions.
**Describe the solution you'd like**
- [ ] Write a way to detect if function is pure and persist that to the cache
- [ ] If function is defined, we have to compile it so that we know if it's pure. As for generic functions we can assume default type to be `Text`
- [ ] Create a way to mark file that was imported purely in the `import_cache`.
- [ ] Compile the pure functions first before resolving the usual import topology
**Describe alternatives you've considered**
N/A
**Additional context**
Let's say that we have file `main.ab`
```ab
import { bar } from "other.ab"
fun aux() {
echo bar()
}
fun foo() {
echo "foo"
}
```
and file `other.ab`.
```ab
import { foo } from "main.ab"
fun bar() {
echo foo() + "bar"
}
```
Even though there is an import cycle, the functions could be imported perfectly fine since `foo` is a pure function that does not rely on the context of the file it was created in.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.