docs: update documentation for May 12 compiler fixes

- CLJNIM_RECOMMENDATIONS.md: mark all 12 recommendations as implemented
- README.md: add --lib-path, first-class functions, multi-arity, rest params
- User guides (EN/BG): add sections for docstrings, multi-arity, rest params,
  keyword-as-function, first-class functions, loop/recur, --lib-path flag
- TASKS.md: add Phase 11 with all BRing compiler fixes
This commit is contained in:
2026-05-12 14:10:31 +03:00
parent a1a65f1c27
commit 7adace4ee1
5 changed files with 307 additions and 109 deletions
+62
View File
@@ -33,6 +33,21 @@ Generates a `.nim` file from Clojure source.
```
Compiles to Nim, then to C, then to a binary, and runs it.
### Global Flags
#### `--lib-path <dir>` — Custom Library Directory
Override the default `lib/` search path. Checked before `CLJNIM_LIB_PATH` env var and built-in paths.
```bash
./cljnim --lib-path ./my_project/lib run app.clj
```
Environment variable alternative:
```bash
export CLJNIM_LIB_PATH=./my_project/lib
./cljnim run app.clj
```
### `read` — Parse and Print AST
```bash
./cljnim read examples/hello.clj
@@ -61,8 +76,24 @@ Shows the Clojure AST as S-expressions.
(defn greet [name]
(println "Hello, " name))
; Function with docstring
(defn greet "Says hello to someone" [name]
(str "Hello, " name))
; Multi-arity function
(defn greet-multi
([name] (greet-multi name "Hello"))
([name greeting] (str greeting ", " name)))
; Function with rest parameters
(defn sum-all [x & rest]
(+ x (reduce + rest)))
; Call a function
(greet "World")
(greet-multi "Alice") ;; => "Hello, Alice"
(greet-multi "Alice" "Hi") ;; => "Hi, Alice"
(sum-all 1 2 3 4) ;; => 10
; Arithmetic
(+ 1 2 3) ; => 6
@@ -88,6 +119,10 @@ Shows the Clojure AST as S-expressions.
; Keywords
(def person {:name "Alice" :age 30})
; Keyword as function (lookup in map)
(:name person) ;; => "Alice"
(:age person) ;; => 30
; Maps and sets use persistent HAMT data structures
; with structural sharing and O(log₃₂ n) operations.
```
@@ -102,6 +137,33 @@ Shows the Clojure AST as S-expressions.
(println (factorial 5)) ; => 120
```
### First-Class Functions
User-defined functions can be passed as values to higher-order functions:
```clojure
(defn square [x] (* x x))
(defn odd? [x] (= 1 (mod x 2)))
(map square [1 2 3 4]) ;; => [1 4 9 16]
(filter odd? [1 2 3 4]) ;; => [1 3]
(apply + [1 2 3]) ;; => 6
```
### Loop / Recur
```clojure
(defn find-header [headers name]
(loop [pairs (seq headers)]
(if (empty? pairs)
nil
(let [[k v] (first pairs)]
(if (= k name)
v
(recur (rest pairs)))))))
(find-header [[:content-type "text/html"] [:accept "*/*"]] :accept)
;; => "*/*"
```
## AI REPL Guide
The JSON REPL is designed for programmatic interaction.