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
+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.3**. 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.4**. 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.3"
version = "0.3.4"
description = "Clyx programming language interpreter"
readme = "README.md"
requires-python = ">=3.7"
+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 ]`.
+3 -1
View File
@@ -1,7 +1,8 @@
# Clyx standard library (in addition to [ :: readf src ])
# Created by Luxferre in 2026, released into the public domain
:: is [ next defw ]
:: is [ next defw ] # alias to :: for constant definitions
:: set [ next next defw ]
:: source [ next src ]
:: then [ ]
:: _start [ next _main swap defw ]
@@ -20,6 +21,7 @@
:: cr [ 10 emit ]
:: space [ 32 emit ]
:: puts [ uncons while [ emit uncons ] drop ]
:: say [ next puts cr ]
:: sqrt [ 0.5 ^ ]
:: tan [ dup sin swap cos / ]
:: cotan [ dup cos swap sin / ]
+8
View File
@@ -78,6 +78,7 @@ if [
" Testing dot: " puts 123 . # Test dot
" Testing emit: " puts 65 emit cr # Test emit
" Testing space: " puts 65 emit space 66 emit cr # Test space
" Testing say: " puts say "hello from say"
" Testing readln: " puts
readln puts cr # Test readln
" Testing .s: " puts .s cr # Test .s
@@ -232,6 +233,13 @@ my_str_word "abc" streq and
:: "my_inline_string_word" [ 400 ]
my_inline_string_word 400 = and
if [ " is PASS" puts cr ] [ " is FAIL" puts cr ] # Test is
set my_set_word [ 500 ]
my_set_word 500 =
set my_set_num 600
my_set_num 600 = and
set my_set_str "hello_set"
my_set_str "hello_set" streq and
if [ " set PASS" puts cr ] [ " set FAIL" puts cr ] # Test set
" _start PASS" puts cr # Test _start (executed via entry point)
# 11. Host Language Evaluation: hseval