From c303bb70b070741cef22e39adf2a59d06e65a2ad Mon Sep 17 00:00:00 2001 From: Luxferre Date: Mon, 6 Jul 2026 12:52:01 +0300 Subject: [PATCH] v0.3.2: source, then, _start --- README.md | 2 +- clyx-python/pyproject.toml | 2 +- clyx_manual.md | 18 +++++++++++++++++- lib.clx | 3 +++ test.clx | 5 ++++- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2d8917a..43a9929 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Clyx aims for maximum portability and can be implemented in any modern runtime e The core spec of Clyx is mostly stable but the standard library is still a work-in-progress. -The most recent Clyx version is **0.3.1**. The version is bumped every time the language core words (aka primitives), the standard library or the REPL get updated. The primitive set is expected to be indefinitely frozen once the version number reaches 1.0. +The most recent Clyx version is **0.3.2**. The version is bumped every time the language core words (aka primitives), the standard library or the REPL get updated. The primitive set is expected to be indefinitely frozen once the version number reaches 1.0. ## Language features diff --git a/clyx-python/pyproject.toml b/clyx-python/pyproject.toml index 5256221..c952321 100644 --- a/clyx-python/pyproject.toml +++ b/clyx-python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "clyx" -version = "0.3.1" +version = "0.3.2" description = "Clyx programming language interpreter" readme = "README.md" requires-python = ">=3.7" diff --git a/clyx_manual.md b/clyx_manual.md index 16b3eb6..fdc82d0 100644 --- a/clyx_manual.md +++ b/clyx_manual.md @@ -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 **45 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 **48 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. @@ -554,3 +554,19 @@ These words are defined in the standard library file `lib.clx` and loaded dynami #### `bitxor` (Bitwise XOR) - **Stack Effect**: `( x y -- x^y )` - **Description**: Pops `y`, pops `x`, and pushes their bitwise XOR result `x ^ y` onto the stack. + +### 10.10 Metaprogramming & System + +#### `source` +- **Syntax**: `source filename` +- **Stack Effect**: `( -- )` (parses filename from the execution stream). +- **Description**: Reads and executes the Clyx source file `filename` dynamically. + +#### `then` +- **Stack Effect**: `( -- )` +- **Description**: A no-op word (does nothing). Useful for syntactic readability in control flow. + +#### `_start` +- **Syntax**: `_start [actions]` +- **Stack Effect**: `( -- )` (parses actions Q-form from the execution stream). +- **Description**: Defines the entry point of the program by setting the `_main` word to execute `[actions]`. diff --git a/lib.clx b/lib.clx index e1cf56c..eac9a8a 100644 --- a/lib.clx +++ b/lib.clx @@ -1,6 +1,9 @@ # Clyx standard library (in addition to [ :: readf src ]) # Created by Luxferre in 2026, released into the public domain +:: source [ next src ] +:: then [ ] +:: _start [ next _main swap defw ] :: if [ next next swap rot cond ] :: while [ next [] swap loop ] :: rot [ [ swap ] dip swap ] diff --git a/test.clx b/test.clx index f48d30d..cffe929 100644 --- a/test.clx +++ b/test.clx @@ -1,7 +1,7 @@ #!/usr/bin/env clyx # Clyx core implementation test suite # Created by Luxferre in 2026, released into the public domain -:: _main [ +_start [ # 1. Stack Manipulation "Testing stack operations..." puts cr @@ -214,6 +214,9 @@ if [ "my_const" [ 99 ] defw my_const 99 = if [ " defw (no-inline) PASS" puts cr ] [ " defw (no-inline) FAIL" puts cr ] # Test defw :: my_inline [ 100 ] my_inline 100 = if [ " :: (inline) PASS" puts cr ] [ " :: (inline) FAIL" puts cr ] # Test inline :: +5 then 5 = if [ " then PASS" puts cr ] [ " then FAIL" puts cr ] # Test then +":: source_test_word [ 99 ]" "test_source.clx" writef drop source test_source.clx source_test_word 99 = if [ "test_source.clx" delf " source PASS" puts cr ] [ "test_source.clx" delf " source FAIL" puts cr ] # Test source +" _start PASS" puts cr # Test _start (executed via entry point) # 11. Host Language Evaluation: hseval # "Testing host language evaluation..." puts cr