v0.3.2: source, then, _start

This commit is contained in:
Luxferre
2026-07-06 12:52:01 +03:00
parent fafc966480
commit c303bb70b0
5 changed files with 26 additions and 4 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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"
+17 -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 **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]`.
+3
View File
@@ -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 ]
+4 -1
View File
@@ -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