You can print text and values from a Lispex program. The calling application supplies external data and decides whether to act on a returned decision.
Print a value
With Native Lispex installed, save this complete source as output.lspx.
(begin (display "answer=") (write 42) (newline) 0)Run it.
lispex run output.lspxThe command prints the following text and exits with code 0. It creates no files.
answer=42
0The program explicitly prints answer=42 and a line break. Native then prints
the form's returned value, 0, on its own line.
| Procedure | What it writes |
|---|---|
display | Text for people to read |
write | A value in readable Lispex notation |
newline | One line break |
println | The same text as display, followed by a line break |
All four procedures return zero values. Interactive execution prints each completed top-level form's values after its explicit output. Batch execution records returned values separately and puts only explicit output in stdout.
Read output when execution stops
The resource profile sets the output-byte limit. Native whole-source execution handles ordinary errors and resource stops differently.
| Outcome | stdout | Exit code |
|---|---|---|
| Successful execution | Explicit output and returned values | 0 |
| Ordinary runtime error | Output committed before the error | 1 |
| Resource limit reached | Empty | 2 |
For example, save this as output-error.lspx.
(display "before\n")
(car 1)lispex run output-error.lspxstdout is before followed by a line break. stderr is shown below.
The command exits with code 1 and creates no files.
E310 output-error.lspx:2:1 car: expected a pair, got 1The CLI reads and normalizes the complete source before evaluating it. A source error at that stage leaves stdout empty. See Resources for resource outcomes.
Assign external work to the application
A supported procedure and a host permission answer different questions. The procedure describes what the rule can compute. The permission determines which external action the calling application may perform.
| Operation | Who handles it |
|---|---|
| Value and text output | Lispex output procedures |
| Source file and standard-input selection | The CLI invocation |
| File and network access | The calling application's adapter |
| Time and randomness | The application supplies them as explicit input |
| Databases and transactions | The application manages state and commits |
| Payments, deployments, and other external actions | The application applies its policy after checking the decision |
Native MCP exchanges source, an optional input value, and results over local standard input and output. It applies its declared byte and time limits. Application adapters pass reviewed data to the rule and use the returned decision.