Native input and built programs
ASPL 0.7.0 · Current release
Line input, EOF, UTF-8, input limits and standalone 0.7.0 execution.
On this page
Native line input
In ASPL 0.7.0, اقرأ_سطر / read_line: () -> string reads one line from inherited stdin. It accepts no arguments or unsafe marker. The builtin prints no prompt, echo or terminator. Print your prompt first; it is visible before the input wait even without a newline. Terminal input, pipes and redirected files use the same reader for aspl run and built programs.
LF and CRLF terminators are removed. An empty line returns an empty string. A final unterminated line is returned once at EOF; a later read traps with input-exhausted. Whitespace, NUL, Arabic marks, direction controls, digits and normalization remain as supplied. Input is data and does not pass through source digit conversion. The reader consumes only the current line, leaving later stdin bytes for later reads or foreign code.
EOF and input failures
The runtime validates each complete line as strict UTF-8. Malformed bytes trap with invalid-input-utf8 and the first invalid byte offset. The default line limit is 65536 payload bytes, excluding LF or CRLF. Exactly that size succeeds; a larger line stops execution with input-line-limit instead of returning truncated text. EOF without a line is a trap, not an empty string. Cancellation or a signal interrupting an input wait is not reported as EOF.
Try piped and redirected input
Download the supplied Input example as input.aspl. It asks for a name, prints the supplied name with its greeting, and returns zero. The English-keyword variant retains the original Arabic prompt and output text.
Execution: Browser and native · ASPL 0.7.0
- No prior knowledge is required to open and check it.
Input lines: ["Mina"]
fn start_main() -> i64 {
print("ما اسمك؟ ");
let name = read_line();
print("مرحبا ");
print(name);
print("\n");
return 0;
}
Expected outcomes
{
"browser": {
"check": "success",
"class": "success",
"output": "ما اسمك؟ مرحبا Mina\n",
"processStatus": 0
},
"native": {
"check": 0,
"status": 0,
"output": "ما اسمك؟ مرحبا Mina\n"
}
}printf 'Mina\n' | aspl run input.aspl
printf 'Mina\n' > name.txt
aspl run input.aspl < name.txt
aspl build -o input input.aspl
printf 'Mina\n' | ./input
./input < /dev/nullThe first three execution forms print ما اسمك؟ مرحبا Mina and a newline. The last command has no line available: it prints the prompt, then traps with input-exhausted, diagnostic stderr and status 5. To choose English diagnostic text for it, use ./input --aspl-diagnostic-language=en < /dev/null.
Standalone program requirements
The published 0.7.0 native templates embed the VM and private bytecode version 7. Private bytecode is not a stable public file format. A built ELF runs after removing source and ASPL from PATH. It still needs the compatible Linux loader and libraries and any external libraries or runtime data its program uses. Building does not verify the availability of those runtime dependencies.
Built programs inherit stdin, stdout, stderr, environment and working directory. Their only accepted controls are native diagnostic options. Use ./program to execute a local file; an executable in the current directory is not automatically on PATH. A native release upgrade or rollback does not change an existing ELF. Rebuild from source with the selected tool when you want that tool's generated program.