v0.3.4: set and say

This commit is contained in:
Luxferre
2026-07-07 10:54:04 +03:00
parent 9296bf2984
commit b1cd35d0ca
5 changed files with 24 additions and 4 deletions
+11 -1
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 Q-forms (special forms to represent data similar to Python or Tcl 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 **49 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 **51 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.
@@ -446,6 +446,11 @@ These words are defined in the standard library file `lib.clx` and loaded dynami
- **Stack Effect**: `( s -- )` or `( [q] -- )`
- **Description**: Outputs a string or Q-form of character codes to standard output character-by-character.
#### `say`
- **Syntax**: `say "message"`
- **Stack Effect**: `( -- )` (parses string literal from the execution stream).
- **Description**: Parses a string literal from the execution stream, prints it to standard output, and outputs a newline. Defined as `[ next puts cr ]`.
#### `readln` (Read Line)
- **Stack Effect**: `( -- s )`
- **Description**: Reads a line of input from standard input and pushes it as a string.
@@ -575,3 +580,8 @@ These words are defined in the standard library file `lib.clx` and loaded dynami
- **Syntax**: `name is [actions]`
- **Stack Effect**: `( name -- )` (parses actions Q-form from the execution stream).
- **Description**: A synonym/helper for `::` used to define inline words. Defined as `[ next defw ]`.
#### `set`
- **Syntax**: `set name [actions]`
- **Stack Effect**: `( -- )` (parses name and actions Q-form from the execution stream).
- **Description**: Defines a word dynamically by parsing its name and its actions Q-form from the execution stream. Defined as `[ next next defw ]`.