Files
modeling-app/docs/kcl
Jonathan Tran 0577b6a984 internal: KCL modules, part 1 (#4149)
Addresses #4080. (Not ready to close it yet.)

# Important

Requires a fix for #4147 before it can work in ZMA.

# Overview

```kcl
// numbers.kcl
export fn inc = (x) => {
  return x + 1
}
```

```kcl
import inc from "numbers.kcl"

answer = inc(41)
```

This also implements multiple imports with optional renaming.

```kcl
import inc, dec from "numbers.kcl"
import identity as id, length as len from "utils.kcl"
```

Note: Imported files _must_ be in the same directory.

Things for a follow-up PR:

- #4147. Currently, we cannot read files in WebAssembly, i.e. ZMA.
- Docs
- Should be an error to `import` anywhere besides the top level. Needs parser restructuring to track the context of a "function body".
- Should be an error to have `export` anywhere besides the top level. It has no effect, but we should tell people it's not valid instead of silently ignoring it.
- Error message for cycle detection is funky because the Rust side doesn't actually know the name of the first file. Message will say "b -> a -> b" instead of "a -> b -> a" when "a" is the top-level file.
- Cache imported files so that they don't need to be re-parsed and re-executed.
2024-10-16 21:48:33 -07:00
..
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-01 08:50:23 -05:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-16 06:58:04 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-16 06:58:04 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-16 21:48:33 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00
2024-10-02 22:05:12 -07:00