binary safety

This commit is contained in:
Luxferre
2026-07-04 12:59:58 +03:00
parent c1c66f9152
commit 147a05d8e0
5 changed files with 102 additions and 23 deletions
+12 -8
View File
@@ -2,7 +2,7 @@
Clyx is a concatenative, stack-oriented programming language designed for simplicity, minimalism, and metaprogramming capabilities. It uses postfix notation (aka Reverse Polish Notation, RPN), where operations are performed on a global stack. Clyx features homoiconicity: code is structured as quotations (lists), which can be manipulated as data and executed dynamically.
This document describes the stack effects and behavior of the **50 primitive core words**, **3 bootstrapped core words**, and **41 standard library words** present in the reference implementation.
This document describes the stack effects and behavior of the **50 primitive core words**, **3 bootstrapped core words**, and **42 standard library words** present in the reference implementation.
The Clyx runtime itself allows the programmer to redefine any already defined word, including the core ones and the ones from the standard library. Unlike e.g. Forth, where words are resolved at compile-time, Clyx words are resolved at runtime, so such redefinitions may affect all previously established behavior. That's why, as a rule, any **predefined** Clyx word, both in the language core and the standard library, must not exceed 6 characters. This is done to encourage programmers to define their own human-readable words (7+ characters long) without any risk of overwriting existing word definitions.
@@ -117,6 +117,14 @@ Any line fragment starting with `#` to the end of the physical source line is re
- **Stack Effect**: `( s -- code )`
- **Description**: Converts the first character of the string `s` to its integer ASCII character code.
### `s2l` (String to List)
- **Stack Effect**: `( val -- [q] )`
- **Description**: Converts the value `val` (if it is a string) to a list of its byte values/integers. If `val` is already a list, it does nothing.
### `l2s` (List to String)
- **Stack Effect**: `( [q] -- s )`
- **Description**: Converts the list of integers `[q]` (character/byte codes) into its string representation `s`. Reverts the operation of `s2l`.
---
## 4. Arithmetic & Mathematics
@@ -322,12 +330,12 @@ These words are defined in Clyx itself during the interpreter's bootstrap phase:
- **Description**: Metaprogramming helper used to define inline words. Defined as `[ next defw ]`.
### `readf` (Read File)
- **Stack Effect**: `( filename -- content )`
- **Description**: Reads the entire contents of the file `filename` and pushes it as a string.
- **Stack Effect**: `( filename -- [content] )`
- **Description**: Reads the entire contents of the file `filename` and pushes it as a list of bytes.
### `src` (Source)
- **Stack Effect**: `( filename -- )`
- **Description**: Reads the file `filename` using `readf` and runs the resulting string of Clyx code in real-time using `i`.
- **Description**: Reads the file `filename` using `readf`, converts the list of bytes to a string using `l2s`, and runs the resulting Clyx code in real-time using `i`.
---
@@ -500,10 +508,6 @@ These words are defined in the standard library file `lib.clx` and loaded dynami
- **Stack Effect**: `( s1 s2 -- [s1_s2] )`
- **Description**: Concatenates `s1` and `s2` (which can be strings or lists of character codes) and pushes the result as a list of character codes representing the concatenated string.
#### `s2l` (String to List)
- **Stack Effect**: `( val -- [q] )`
- **Description**: Converts the value `val` (if it is a string) to a list of its ASCII character codes. If `val` is already a list, it does nothing.
### 10.8 List Operations
#### `qpush` (Quotation Push)