AtlatestRepositorycore-channel

core-channel / tree / build / dev / lib / sigilcore.json

1{
2 "module": "(sigil core)",
3 "package": "sigil-stdlib",
4 "source": "/home/daviwil/.sigil/deps/codeberg-sigil-sigil-2e452e2f641fcf63be4e88a2748b34791543be8f/packages/sigil-stdlib/src/sigil/core.sgl",
5 "description": "(sigil core) - Core Language Primitives\n\nThe foundation of Sigil. This module is automatically imported into every\nmodule and provides essential procedures, macros, and syntax forms.\n\n## List Operations\n\n```scheme\n(append '(1 2) '(3 4)) ; => (1 2 3 4)\n(reverse '(1 2 3)) ; => (3 2 1)\n(filter even? '(1 2 3 4 5)) ; => (2 4)\n(map (lambda (x) (* x 2)) '(1 2 3)) ; => (2 4 6)\n(fold + 0 '(1 2 3 4)) ; => 10\n```\n\n## Control Flow\n\n```scheme\n(cond\n ((< x 0) \"negative\")\n ((= x 0) \"zero\")\n (else \"positive\"))\n\n(case color\n ((red green blue) \"primary\")\n ((cyan magenta yellow) \"secondary\")\n (else \"other\"))\n\n(when (> x 0) (do-something))\n(unless (null? lst) (process lst))\n```\n\n## Records\n\n```scheme\n(define-record <point> (x) (y))\n(define p (point 10 20))\n(point-x p) ; => 10\n(point? p) ; => #t\n```\n\n## Exception Handling\n\n```scheme\n(error \"Something went wrong: ~a\" details)\n(raise (make-exception 'not-found \"Resource missing\" '()))\n```\n\n## Keyword Arguments\n\n```scheme\n(define (greet name (keys: (greeting \"Hello\")))\n (format \"~a, ~a!\" greeting name))\n\n(greet \"World\") ; => \"Hello, World!\"\n(greet \"World\" greeting: \"Hi\") ; => \"Hi, World!\"\n```\n\nThis module uses bootstrap primitives (`%make-module`, `%module-export!`)\ninstead of `define-library` for internal bootstrapping reasons.",
6 "exports": [
7 {
8 "name": "assq-ref",
9 "kind": "procedure",
10 "description": "Look up a key in an association list using eq?, returning the value or a default.\n\nReturns the cdr of the first pair whose car is eq? to KEY, or DEFAULT\nif no match is found. If DEFAULT is not provided, returns #f.\n\n```scheme\n(assq-ref 'b '((a . 1) (b . 2) (c . 3))) ; => 2\n(assq-ref 'x '((a . 1) (b . 2)) 'not-found) ; => not-found\n(assq-ref 'x '((a . 1) (b . 2))) ; => #f\n```",
11 "line": 80
12 },
13 {
14 "name": "assv-ref",
15 "kind": "procedure",
16 "description": "Look up a key in an association list using eqv?, returning the value or a default.\n\nReturns the cdr of the first pair whose car is eqv? to KEY, or DEFAULT\nif no match is found. If DEFAULT is not provided, returns #f.\n\n```scheme\n(assv-ref 1 '((1 . \"one\") (2 . \"two\") (3 . \"three\"))) ; => \"one\"\n(assv-ref 4 '((1 . \"one\") (2 . \"two\")) 'not-found) ; => not-found\n(assv-ref 4 '((1 . \"one\") (2 . \"two\"))) ; => #f\n```",
17 "line": 97
18 },
19 {
20 "name": "zero?",
21 "kind": "procedure",
22 "description": "Check if a number is zero.\n\n```scheme\n(zero? 0) ; => #t\n(zero? 1) ; => #f\n(zero? -1) ; => #f\n(zero? 0.0) ; => #t\n```",
23 "line": 118
24 },
25 {
26 "name": "positive?",
27 "kind": "procedure",
28 "description": "Check if a number is positive (greater than zero).\n\n```scheme\n(positive? 5) ; => #t\n(positive? 0) ; => #f\n(positive? -3) ; => #f\n(positive? 0.1) ; => #t\n```",
29 "line": 129
30 },
31 {
32 "name": "negative?",
33 "kind": "procedure",
34 "description": "Check if a number is negative (less than zero).\n\n```scheme\n(negative? -5) ; => #t\n(negative? 0) ; => #f\n(negative? 3) ; => #f\n(negative? -0.1) ; => #t\n```",
35 "line": 140
36 },
37 {
38 "name": "append",
39 "kind": "procedure",
40 "description": "Concatenate any number of lists into one.\n\nReturns a new list with elements from all lists in order.\nThe last list is shared (not copied).\n\n```scheme\n(append '(1 2) '(3 4)) ; => (1 2 3 4)\n(append '(a) '(b) '(c d)) ; => (a b c d)\n(append '(1 2) '()) ; => (1 2)\n```",
41 "line": 194
42 },
43 {
44 "name": "reverse",
45 "kind": "procedure",
46 "description": "Reverse the order of elements in a list.\n\nReturns a new list with elements in reverse order.\n\n```scheme\n(reverse '(1 2 3)) ; => (3 2 1)\n(reverse '(a b c d)) ; => (d c b a)\n(reverse '()) ; => ()\n```",
47 "line": 223
48 },
49 {
50 "name": "list-length-internal",
51 "kind": "procedure",
52 "description": "list-length-internal - Tail-recursive length",
53 "line": 238
54 },
55 {
56 "name": "%syntax-has-local-binding?",
57 "kind": "procedure",
58 "description": "Check if a syntax object has local-binding metadata in its substs.\nUsed for free-identifier=? comparison in literal matching.",
59 "line": 354
60 },
61 {
62 "name": "%register-macro-captures!",
63 "kind": "procedure",
64 "description": "Register captured locals for a macro instance.\nReturns the capture-id to use for retrieval.",
65 "line": 703
66 },
67 {
68 "name": "%macro-capture",
69 "kind": "procedure",
70 "description": "Retrieve a captured value at runtime.\ncapture-id is the unique ID for the macro instance.\nsym is the symbol name of the captured local.",
71 "line": 717
72 },
73 {
74 "name": "make-syntax-rules-transformer",
75 "kind": "procedure",
76 "description": "syntax-rules transformer generator\n\nIn syntax-rules, the first element of each pattern is the macro keyword.\nIt should be treated as a literal (matched exactly, not bound as a variable).\n\ncaptured-locals is an alist of (symbol . value) for free identifiers that\nwere local bindings at macro definition time. This enables proper hygiene\nfor macros defined in local scopes.",
77 "line": 738
78 },
79 {
80 "name": "caar",
81 "kind": "procedure",
82 "description": "Get the car of the car: `(car (car x))`.\n\n```scheme\n(caar '((1 2) 3)) ; => 1\n```",
83 "line": 963
84 },
85 {
86 "name": "cadr",
87 "kind": "procedure",
88 "description": "Get the car of the cdr (second element): `(car (cdr x))`.\n\n```scheme\n(cadr '(1 2 3)) ; => 2\n```",
89 "line": 971
90 },
91 {
92 "name": "cdar",
93 "kind": "procedure",
94 "description": "Get the cdr of the car: `(cdr (car x))`.\n\n```scheme\n(cdar '((1 2 3) 4)) ; => (2 3)\n```",
95 "line": 979
96 },
97 {
98 "name": "cddr",
99 "kind": "procedure",
100 "description": "Get the cdr of the cdr (tail after second): `(cdr (cdr x))`.\n\n```scheme\n(cddr '(1 2 3 4)) ; => (3 4)\n```",
101 "line": 987
102 },
103 {
104 "name": "caadr",
105 "kind": "procedure",
106 "description": "Get `(car (car (cdr x)))`.",
107 "line": 997
108 },
109 {
110 "name": "cadar",
111 "kind": "procedure",
112 "description": "Get `(car (cdr (car x)))` - useful for alist value access.",
113 "line": 1001
114 },
115 {
116 "name": "caddr",
117 "kind": "procedure",
118 "description": "Get the third element: `(car (cdr (cdr x)))`.\n\n```scheme\n(caddr '(1 2 3 4)) ; => 3\n```",
119 "line": 1009
120 },
121 {
122 "name": "cdadr",
123 "kind": "procedure",
124 "description": "Get `(cdr (car (cdr x)))`.",
125 "line": 1015
126 },
127 {
128 "name": "cdddr",
129 "kind": "procedure",
130 "description": "Get the tail after third element: `(cdr (cdr (cdr x)))`.\n\n```scheme\n(cdddr '(1 2 3 4 5)) ; => (4 5)\n```",
131 "line": 1025
132 },
133 {
134 "name": "cadddr",
135 "kind": "procedure",
136 "description": "Get the fourth element: `(car (cdr (cdr (cdr x))))`.\n\n```scheme\n(cadddr '(1 2 3 4 5)) ; => 4\n```",
137 "line": 1044
138 },
139 {
140 "name": "%syntax-identifier?",
141 "kind": "procedure",
142 "description": "Check if a syntax object is an identifier (syntax-wrapped symbol)",
143 "line": 1062
144 },
145 {
146 "name": "%syntax-pattern-match",
147 "kind": "procedure",
148 "description": "Pattern match on syntax objects, preserving syntax in bindings.\nReturns an alist of (pattern-var . syntax-value) or #f if no match.\nUnlike the plain %pattern-match, this keeps syntax wrappers on bindings.",
149 "line": 1071
150 },
151 {
152 "name": "%syntax-match-ellipsis",
153 "kind": "procedure",
154 "description": "Match ellipsis patterns on syntax, building lists of bindings",
155 "line": 1155
156 },
157 {
158 "name": "%syntax-collect-pattern-vars",
159 "kind": "procedure",
160 "description": "Collect pattern variables from a pattern (for ellipsis handling)\nReturns plain symbols, stripping syntax wrappers from pattern variable names.",
161 "line": 1180
162 },
163 {
164 "name": "%%syntax-match-ellipsis-exprs",
165 "kind": "procedure",
166 "description": "Match multiple expressions against a sub-pattern, accumulating bindings",
167 "line": 1203
168 },
169 {
170 "name": "%syntax-pattern-match-rest",
171 "kind": "procedure",
172 "description": "Continue pattern matching after ellipsis",
173 "line": 1239
174 },
175 {
176 "name": "%syntax-template-instantiate",
177 "kind": "procedure",
178 "description": "Instantiate a template with syntax bindings.\nThis is the core of hygienic template construction.\n- Pattern variables are substituted with their bound syntax values\n- Introduced bindings are renamed with gensyms for hygiene\n- Free identifiers with capture-id emit (%macro-capture capture-id 'sym) forms\n- Other free identifiers are wrapped with definition-site module name",
179 "line": 1263
180 },
181 {
182 "name": "%syntax-expand-ellipsis",
183 "kind": "procedure",
184 "description": "Expand an ellipsis template",
185 "line": 1485
186 },
187 {
188 "name": "%%syntax-expand-ellipsis-hygienic",
189 "kind": "procedure",
190 "description": "Hygienic version of ellipsis expansion that uses renames and capture-id",
191 "line": 1538
192 },
193 {
194 "name": "%match",
195 "kind": "variable",
196 "description": "Default binding for %match used outside syntax-case / with-syntax.\nsyntax-case and with-syntax establish inner `let` bindings that shadow\nthis top-level value with the actual match alist. When `(syntax tmpl)`\nor `#'tmpl` is used at top level (outside either form), the reference\nto %match resolves here, giving `%syntax-template-instantiate` an\nempty bindings alist -- no pattern-variable substitution occurs and\nthe template is returned as a plain syntax object.",
197 "line": 1664
198 },
199 {
200 "name": "%syntax-wrap-result",
201 "kind": "procedure",
202 "description": "Post-process the result of %syntax-template-instantiate so that\n`(syntax tmpl)` always produces a syntax object. When the template\nhas no pattern-variable or module-renamed identifiers to substitute,\n%syntax-template-instantiate returns the raw datum unchanged; wrap\nit so callers like (syntax? #'foo) see a syntax object.",
203 "line": 1672
204 },
205 {
206 "name": "%syntax-template-has-symbols?",
207 "kind": "procedure",
208 "description": "Determine whether a template datum contains any symbols that could\nbe pattern variables. Templates with no symbols at all (numbers,\nstrings, booleans, empty lists, nested lists of the same) have no\npossible pattern-variable references and can be emitted as a plain\nsyntax wrap without consulting %match.",
209 "line": 1681
210 },
211 {
212 "name": "%generate-pattern-var-bindings",
213 "kind": "procedure",
214 "description": "Generate let-bindings for pattern variables from a match result\nTakes: pattern, literals list, and the binding alist variable name\nReturns: list of (var (cdr (assq 'var bindings-var)))\nNote: Variable names are stripped of syntax to work as proper binding names.",
215 "line": 1698
216 },
217 {
218 "name": "%qs-head-is?",
219 "kind": "procedure",
220 "description": "Head-symbol predicate -- is tmpl a pair whose car (possibly\nsyntax-wrapped) is the symbol `sym`?",
221 "line": 1845
222 },
223 {
224 "name": "%qs-inner",
225 "kind": "procedure",
226 "description": "Extract the single argument of a one-argument form `(X arg)`. Works\nthrough syntax-wrapping because car/cdr unwrap one level on the\nregister VM.",
227 "line": 1856
228 },
229 {
230 "name": "%qs-walk",
231 "kind": "procedure",
232 "description": "Rewrite a quasisyntax list element-by-element. Returns a cons of\n(new-list . escape-bindings) where escape-bindings is a list of\n(kind gensym expr): kind is 'single or 'splice.\n\nThe only difference between %qs-walk-list and %qs-walk's pair arm\nis that at depth 0, a `(unsyntax-splicing expr)` ELEMENT of a list\nrewrites to two sibling entries (<gensym> ...) so the surrounding\nlist instantiator sees `<gensym> ...` at the right nesting level.",
233 "line": 1868
234 },
235 {
236 "name": "dynamic-wind",
237 "kind": "procedure",
238 "description": "dynamic-wind - establish before/after thunks around body\nR7RS: (dynamic-wind before thunk after)\nCalls before, then thunk, then after. If a continuation captured inside\nthunk is invoked from outside, after is called on exit and before on re-entry.",
239 "line": 2198
240 },
241 {
242 "name": "%qq-unquote?",
243 "kind": "procedure",
244 "description": "The quasiquote macro (invoked with backtick `) allows building\nlists with some parts evaluated and some quoted.\n\nExamples:\n `(a b c) => '(a b c)\n `(a ,x c) => (list 'a x 'c)\n `(a ,@xs c) => (append (list 'a) xs (list 'c))\n `(a (b ,c) d) => (list 'a (list 'b c) 'd)\n\nImplementation approach:\n- Walk the quasiquoted form\n- For atoms: quote them\n- For (unquote x): return x directly\n- For lists containing unquote-splicing: use append\n- For other lists: use cons or list\nCheck if a form is (unquote x)",
245 "line": 2497
246 },
247 {
248 "name": "%qq-unquote-splicing?",
249 "kind": "procedure",
250 "description": "Check if a form is (unquote-splicing x)",
251 "line": 2504
252 },
253 {
254 "name": "%qq-has-splicing?",
255 "kind": "procedure",
256 "description": "Check if a list contains any unquote-splicing at the top level",
257 "line": 2511
258 },
259 {
260 "name": "%qq-expand",
261 "kind": "procedure",
262 "description": "Expand a quasiquoted expression into list-building code",
263 "line": 2522
264 },
265 {
266 "name": "%%qq-expand-list",
267 "kind": "procedure",
268 "description": "Expand a list without splicing using list",
269 "line": 2542
270 },
271 {
272 "name": "%%%qq-expand-list-with-splicing",
273 "kind": "procedure",
274 "description": "Expand a list that contains splicing using append",
275 "line": 2564
276 },
277 {
278 "name": "%qq-collect-segments",
279 "kind": "procedure",
280 "description": "Collect segments for append: quoted items get wrapped in (list ...),\nspliced items are included directly",
281 "line": 2573
282 },
283 {
284 "name": "%qq-collect-one-segment",
285 "kind": "procedure",
286 "description": "Collect one segment: either a single splice, or multiple non-spliced items\nReturns (segment . remaining-list)",
287 "line": 2585
288 },
289 {
290 "name": "%qq-collect-non-spliced",
291 "kind": "procedure",
292 "description": "Collect consecutive non-spliced items\nReturns (items . remaining-list)",
293 "line": 2600
294 },
295 {
296 "name": "map",
297 "kind": "procedure",
298 "description": "Apply a procedure to each element of a list, returning a new list.\n\n```scheme\n(map (lambda (x) (* x 2)) '(1 2 3)) ; => (2 4 6)\n(map symbol->string '(a b c)) ; => (\"a\" \"b\" \"c\")\n```\n\nFor multi-list mapping, use `list-map` from `(sigil list)`:\n```scheme\n(import (sigil list))\n(list-map + '(1 2 3) '(10 20 30)) ; => (11 22 33)\n```",
299 "line": 2646
300 },
301 {
302 "name": "any",
303 "kind": "procedure",
304 "description": "Test if any element in a list satisfies a predicate.\n\nReturns `#t` as soon as one matching element is found, `#f` otherwise.\n\n```scheme\n(any even? '(1 3 4 5)) ; => #t\n(any even? '(1 3 5 7)) ; => #f\n(any null? '(() (1) (2))) ; => #t\n```",
305 "line": 2662
306 },
307 {
308 "name": "every",
309 "kind": "procedure",
310 "description": "Test if all elements in a list satisfy a predicate.\n\nReturns `#t` if the predicate is true for every element, `#f` otherwise.\n\n```scheme\n(every number? '(1 2 3)) ; => #t\n(every even? '(2 4 5)) ; => #f\n(every symbol? '()) ; => #t (vacuously true)\n```",
311 "line": 2678
312 },
313 {
314 "name": "for-each",
315 "kind": "procedure",
316 "description": "Apply a procedure to each element of a list for side effects.\n\nLike `map`, but doesn't collect results—used for side effects like\nprinting.\n\n```scheme\n(for-each println '(\"a\" \"b\" \"c\")) ; prints a, b, c on separate lines\n(for-each (lambda (x) (set! sum (+ sum x))) '(1 2 3))\n```\n\nFor multi-list iteration, use `list-for-each` from `(sigil list)`:\n```scheme\n(import (sigil list))\n(list-for-each (lambda (a b) (println \"~a\" (+ a b))) '(1 2) '(10 20))\n```",
317 "line": 2700
318 },
319 {
320 "name": "filter",
321 "kind": "procedure",
322 "description": "Return elements that satisfy a predicate.\n\nCreates a new list containing only elements for which the predicate\nreturns `#t`.\n\n```scheme\n(filter even? '(1 2 3 4 5)) ; => (2 4)\n(filter string? '(1 \"a\" 2 \"b\")) ; => (\"a\" \"b\")\n(filter (lambda (x) (> x 0)) '(-1 0 1 2)) ; => (1 2)\n```",
323 "line": 2718
324 },
325 {
326 "name": "filter-map",
327 "kind": "procedure",
328 "description": "Map a procedure over a list, keeping only non-#f results.\n\nApplies `proc` to each element and collects non-false results.\nThis is equivalent to `(filter values (map proc lst))` but more efficient.\n\n```scheme\n(filter-map (lambda (x) (if (even? x) (* x 2) #f)) '(1 2 3 4)) ; => (4 8)\n(filter-map (lambda (x) (and (> x 0) x)) '(-1 2 -3 4)) ; => (2 4)\n```",
329 "line": 2750
330 },
331 {
332 "name": "partition",
333 "kind": "procedure",
334 "description": "Partition a list into two lists based on a predicate.\n\nReturns two values: a list of elements satisfying the predicate,\nand a list of elements that don't.\n\n```scheme\n(partition even? '(1 2 3 4 5 6)) ; => (2 4 6) (1 3 5)\n(partition positive? '(-1 2 -3 4)) ; => (2 4) (-1 -3)\n```",
335 "line": 2784
336 },
337 {
338 "name": "take",
339 "kind": "procedure",
340 "description": "Return the first n elements of a list.\n\nIf the list has fewer than n elements, returns the entire list.\n\n```scheme\n(take '(1 2 3 4 5) 3) ; => (1 2 3)\n(take '(a b) 5) ; => (a b)\n(take '() 3) ; => ()\n```",
341 "line": 2802
342 },
343 {
344 "name": "skip",
345 "kind": "procedure",
346 "description": "Skip the first n elements of a list.\n\nReturns the tail of the list after dropping n elements.\nIf the list has fewer than n elements, returns an empty list.\n\n```scheme\n(skip '(1 2 3 4 5) 2) ; => (3 4 5)\n(skip '(a b) 5) ; => ()\n(skip '(1 2 3) 0) ; => (1 2 3)\n```",
347 "line": 2818
348 },
349 {
350 "name": "remove",
351 "kind": "procedure",
352 "description": "Remove all occurrences of an item from a list.\n\nUses `equal?` for comparison. Returns a new list with all\nelements equal to `item` removed.\n\n```scheme\n(remove 2 '(1 2 3 2 4)) ; => (1 3 4)\n(remove 'a '(a b a c a)) ; => (b c)\n```",
353 "line": 2833
354 },
355 {
356 "name": "find",
357 "kind": "procedure",
358 "description": "Find the first element satisfying a predicate.\n\nReturns the first element for which the predicate returns `#t`,\nor `#f` if no element matches.\n\n```scheme\n(find even? '(1 3 4 5)) ; => 4\n(find even? '(1 3 5)) ; => #f\n(find (lambda (x) (> x 10)) '(5 15 25)) ; => 15\n```",
359 "line": 2847
360 },
361 {
362 "name": "assoc-ref",
363 "kind": "procedure",
364 "description": "Get the value for a key in an alist, or a default if not found.\n\nUses `equal?` for key comparison.\n\n```scheme\n(assoc-ref 'b '((a . 1) (b . 2) (c . 3))) ; => 2\n(assoc-ref 'd '((a . 1) (b . 2)) 'not-found) ; => not-found\n(assoc-ref 'd '((a . 1) (b . 2))) ; => #f\n```",
365 "line": 2875
366 },
367 {
368 "name": "fold-left",
369 "kind": "procedure",
370 "description": "Reduce a list from the left.\n\nApplies `(proc accumulator element)` for each element, threading\nthe result as the accumulator for the next call.\n\n```scheme\n(fold-left + 0 '(1 2 3 4)) ; => 10\n(fold-left cons '() '(1 2 3)) ; => ((((() . 1) . 2) . 3)\n(fold-left max 0 '(3 1 4 1 5)) ; => 5\n```",
371 "line": 2892
372 },
373 {
374 "name": "fold-right",
375 "kind": "procedure",
376 "description": "Reduce a list from the right.\n\nApplies `(proc element accumulator)` starting from the last element.\nNote: Not tail-recursive—may stack overflow on very long lists.\n\n```scheme\n(fold-right cons '() '(1 2 3)) ; => (1 2 3)\n(fold-right + 0 '(1 2 3 4)) ; => 10\n(fold-right list '() '(a b c)) ; => (a (b (c ())))\n```",
377 "line": 2908
378 },
379 {
380 "name": "fold",
381 "kind": "variable",
382 "description": "Reduce a list (alias for `fold-left`).\n\nThe most common fold operation. See `fold-left` for details.\n\n```scheme\n(fold + 0 '(1 2 3 4)) ; => 10\n```",
383 "line": 2921
384 },
385 {
386 "name": "even?",
387 "kind": "procedure",
388 "description": "even? - Test if an integer is even\n(even? 4) => #t\n(even? 3) => #f",
389 "line": 2927
390 },
391 {
392 "name": "odd?",
393 "kind": "procedure",
394 "description": "odd? - Test if an integer is odd\n(odd? 3) => #t\n(odd? 4) => #f",
395 "line": 2934
396 },
397 {
398 "name": "iota",
399 "kind": "procedure",
400 "description": "iota - Generate a list of integers\n(iota 5) => (0 1 2 3 4)\n(iota 5 1) => (1 2 3 4 5)\n(iota 5 0 2) => (0 2 4 6 8)",
401 "line": 2942
402 },
403 {
404 "name": "make-list",
405 "kind": "procedure",
406 "description": "Create a list of n copies of fill.\n\n```scheme\n(make-list 3 'a) ; => (a a a)\n(make-list 5) ; => (#f #f #f #f #f)\n(make-list 0 'x) ; => ()\n```\n\nIf fill is omitted, #f is used.",
407 "line": 2960
408 },
409 {
410 "name": "make-string",
411 "kind": "procedure",
412 "description": "Create a string of n copies of char.\n\n```scheme\n(make-string 3 #\\a) ; => \"aaa\"\n(make-string 5) ; => \" \"\n(make-string 0 #\\x) ; => \"\"\n```\n\nIf char is omitted, space is used.",
413 "line": 2977
414 },
415 {
416 "name": "vector-for-each",
417 "kind": "procedure",
418 "description": "Apply procedure to each element of a vector for side effects.\n(vector-for-each display #(1 2 3)) displays 123",
419 "line": 2993
420 },
421 {
422 "name": "vector-map",
423 "kind": "procedure",
424 "description": "Apply procedure to each element, return vector of results.\n(vector-map (lambda (x) (* x 2)) #(1 2 3)) => #(2 4 6)",
425 "line": 3004
426 },
427 {
428 "name": "vector-filter",
429 "kind": "procedure",
430 "description": "Return a new vector containing only elements that satisfy the predicate.\n(vector-filter even? #(1 2 3 4 5)) => #(2 4)",
431 "line": 3017
432 },
433 {
434 "name": "vector-fold",
435 "kind": "procedure",
436 "description": "Fold a procedure over a vector from left to right.\n(vector-fold + 0 #(1 2 3 4 5)) => 15",
437 "line": 3040
438 },
439 {
440 "name": "string-for-each",
441 "kind": "procedure",
442 "description": "Apply procedure to each character of a string for side effects.\n(string-for-each display \"abc\") displays abc\n\nO(n): walks the string with a native char cursor (one forward UTF-8\ndecode per character) instead of per-index string-ref, which is\nO(index) on non-ASCII strings and made this loop O(n^2). The proc is\ncalled from bytecode (not from a C callback loop), so procs that\nsuspend (await/yield in a fiber) keep full continuation support —\nsee topics/sigil-native-reentry-fiber-amputation for why a native\ncallback loop would not.",
443 "line": 3070
444 },
445 {
446 "name": "string-map",
447 "kind": "procedure",
448 "description": "Apply procedure to each character, return string of results.\n(string-map char-upcase \"abc\") => \"ABC\"\n\nO(n) via a native char cursor (see string-for-each above).",
449 "line": 3084
450 },
451 {
452 "name": "error-object?",
453 "kind": "procedure",
454 "description": "Test if a value is an error object (exception).",
455 "line": 3138
456 },
457 {
458 "name": "error-object-message",
459 "kind": "procedure",
460 "description": "Get the message from an error object.",
461 "line": 3142
462 },
463 {
464 "name": "error-object-irritants",
465 "kind": "procedure",
466 "description": "Get the irritants from an error object.",
467 "line": 3146
468 },
469 {
470 "name": "error-object-type",
471 "kind": "procedure",
472 "description": "Get the type/kind of an error object.",
473 "line": 3150
474 },
475 {
476 "name": "file-error?",
477 "kind": "procedure",
478 "description": "Test if an error is file-related.",
479 "line": 3154
480 },
481 {
482 "name": "read-error?",
483 "kind": "procedure",
484 "description": "Test if an error is read-related.",
485 "line": 3160
486 },
487 {
488 "name": "*reset-tag*",
489 "kind": "variable",
490 "description": "Default prompt tag for reset/shift\nExported so that reset/shift macro expansions can reference it.",
491 "line": 3179
492 },
493 {
494 "name": "call-with-port",
495 "kind": "procedure",
496 "description": "call-with-port - R7RS procedure for safe port handling\nCalls proc with port as argument, closes port when proc returns,\nand returns the result of proc.\n\nUsage:\n (call-with-port (open-input-file \"data.txt\")\n (lambda (port)\n (read-line port)))",
497 "line": 3226
498 },
499 {
500 "name": "call-with-output-string",
501 "kind": "procedure",
502 "description": "call-with-output-string - R7RS procedure returning what proc wrote\nCalls proc with a fresh string output port and returns the accumulated\nstring.\n\nUsage:\n (call-with-output-string\n (lambda (port)\n (display \"x = \" port)\n (display 42 port)))\n ; => \"x = 42\"\n\nThis lives in core, rather than only in (sigil io) where its siblings\nare, because (sigil user) -- the module the REPL, `sigil eval` and\n`(interaction-environment)` evaluate in -- imports (sigil core) and\nnothing else. Formatting a caught exception into a string at a prompt\nneeds this and should not require an explicit import.\n\n(sigil io) keeps its own identical definition; both export the name, as\nboth already do for port?, output-port? and the other port predicates.\n\nNo `(: procedure? -> string?)` spec here on purpose: %define is the\nbootstrap primitive and does not strip type specs, so one would survive\nas the first body expression and raise `unbound variable ':'` when\ncalled.",
503 "line": 3256
504 },
505 {
506 "name": "*exception-type-tag*",
507 "kind": "variable",
508 "description": "Exception type tag",
509 "line": 3305
510 },
511 {
512 "name": "make-exception",
513 "kind": "procedure",
514 "description": "Create an exception with the given kind, message, and irritants.",
515 "line": 3308
516 },
517 {
518 "name": "make-exception-with-trace",
519 "kind": "procedure",
520 "description": "Create an exception with stack trace.",
521 "line": 3313
522 },
523 {
524 "name": "exception?",
525 "kind": "procedure",
526 "description": "Check if obj is an exception.",
527 "line": 3318
528 },
529 {
530 "name": "exception-kind",
531 "kind": "procedure",
532 "description": "Get the kind of an exception (e.g., 'error, 'type-error).",
533 "line": 3325
534 },
535 {
536 "name": "exception-message",
537 "kind": "procedure",
538 "description": "Get the message from an exception.",
539 "line": 3332
540 },
541 {
542 "name": "exception-irritants",
543 "kind": "procedure",
544 "description": "Get the irritants (additional data) from an exception.",
545 "line": 3341
546 },
547 {
548 "name": "exception-stack-trace",
549 "kind": "procedure",
550 "description": "Get the stack trace from an exception.",
551 "line": 3348
552 },
553 {
554 "name": "*exception-prompt-tag*",
555 "kind": "variable",
556 "description": "Exception prompt tag",
557 "line": 3357
558 },
559 {
560 "name": "default-exception-handler",
561 "kind": "procedure",
562 "description": "Default handler - prints error and returns #f",
563 "line": 3363
564 },
565 {
566 "name": "*current-handler*",
567 "kind": "variable",
568 "description": "Current exception handler",
569 "line": 3378
570 },
571 {
572 "name": "current-exception-handler",
573 "kind": "procedure",
574 "description": "Get the current exception handler.",
575 "line": 3381
576 },
577 {
578 "name": "raise",
579 "kind": "procedure",
580 "description": "Raise an exception (non-continuable).\nThe compiler compiles direct calls to OP_RAISE (which handles stack\ntrace attachment and searches the VM exception handler stack).\nThis Scheme wrapper exists for first-class use (e.g. apply/map).",
581 "line": 3389
582 },
583 {
584 "name": "raise-continuable",
585 "kind": "procedure",
586 "description": "Raise a continuable exception.\nThe handler can return a value to continue execution.",
587 "line": 3395
588 },
589 {
590 "name": "error",
591 "kind": "procedure",
592 "description": "Convenience function to raise an error exception.\n(error \"message\" irritant ...)",
593 "line": 3401
594 },
595 {
596 "name": "with-exception-handler",
597 "kind": "procedure",
598 "description": "Install an exception handler and execute thunk (R6RS style).\nHandler is a procedure taking the exception.\nThunk is the body to execute.",
599 "line": 3408
600 },
601 {
602 "name": "run-with-error-handler",
603 "kind": "procedure",
604 "description": "Run a thunk with a default error handler that prints and exits.\nUsed by sigil-run to wrap the entry point so errors are visible.\nApplications can install their own handlers (like REPL does) to override.\n\nThe report goes to CURRENT-ERROR-PORT (t-2d9270). It used to use plain\n`display`/`write`, which target current-output-port, so a bytecode bundle\nannounced a fatal error on STDOUT and exited 1 — mute to any caller reading\nonly stderr, and invisible whenever stdout was a pipe nobody drained. The\nNATIVE backend already reported on stderr, so the two backends disagreed\nabout where a fatal error goes, and the bytecode side lost.\n\nThat divergence is why the silently-discarded-library-clause defect\n(t-460dda) stayed invisible for so long: the compiler DID raise `unbound\nvariable`, and the message went down an unread stdout.\n\nThe exit code is deliberately unchanged. Only the stream moves.",
605 "line": 3442
606 },
607 {
608 "name": "string-ref",
609 "kind": "procedure",
610 "description": "Return the character at position k in the string.\n\n```scheme\n(string-ref \"hello\" 0) ; => #\\h\n(string-ref \"hello\" 4) ; => #\\o\n```\n\nThe index k must be a non-negative integer less than the string length.\nRaises an error if the index is out of bounds.",
611 "line": 3690
612 },
613 {
614 "name": "string-length",
615 "kind": "procedure",
616 "description": "Return the number of characters in the string.\n\n```scheme\n(string-length \"hello\") ; => 5\n(string-length \"\") ; => 0\n(string-length \"λ\") ; => 1 (counts characters, not bytes)\n```",
617 "line": 3700
618 },
619 {
620 "name": "string-append",
621 "kind": "procedure",
622 "description": "Concatenate zero or more strings into a single string.\n\n```scheme\n(string-append \"hello\" \" \" \"world\") ; => \"hello world\"\n(string-append) ; => \"\"\n(string-append \"only\") ; => \"only\"\n```",
623 "line": 3710
624 },
625 {
626 "name": "substring",
627 "kind": "procedure",
628 "description": "Extract a substring from start (inclusive) to end (exclusive).\n\n```scheme\n(substring \"hello\" 1 4) ; => \"ell\"\n(substring \"hello\" 0 5) ; => \"hello\"\n(substring \"hello\" 2 2) ; => \"\"\n```\n\nBoth start and end must be valid indices where 0 <= start <= end <= length.",
629 "line": 3722
630 },
631 {
632 "name": "string=?",
633 "kind": "procedure",
634 "description": "Test if two strings are equal.\n\n```scheme\n(string=? \"hello\" \"hello\") ; => #t\n(string=? \"hello\" \"Hello\") ; => #f (case-sensitive)\n(string=? \"\" \"\") ; => #t\n```",
635 "line": 3732
636 },
637 {
638 "name": "char=?",
639 "kind": "procedure",
640 "description": "Test if two characters are equal.\n\n```scheme\n(char=? #\\a #\\a) ; => #t\n(char=? #\\a #\\A) ; => #f\n```",
641 "line": 3741
642 },
643 {
644 "name": "char<?",
645 "kind": "procedure",
646 "description": "Test if the first character is less than the second.\n\n```scheme\n(char<? #\\a #\\b) ; => #t\n(char<? #\\b #\\a) ; => #f\n(char<? #\\A #\\a) ; => #t (uppercase before lowercase in Unicode)\n```",
647 "line": 3751
648 },
649 {
650 "name": "char<=?",
651 "kind": "procedure",
652 "description": "Test if the first character is less than or equal to the second.\n\n```scheme\n(char<=? #\\a #\\a) ; => #t\n(char<=? #\\a #\\b) ; => #t\n(char<=? #\\b #\\a) ; => #f\n```",
653 "line": 3761
654 },
655 {
656 "name": "char>?",
657 "kind": "procedure",
658 "description": "Test if the first character is greater than the second.\n\n```scheme\n(char>? #\\b #\\a) ; => #t\n(char>? #\\a #\\b) ; => #f\n```",
659 "line": 3770
660 },
661 {
662 "name": "char>=?",
663 "kind": "procedure",
664 "description": "Test if the first character is greater than or equal to the second.\n\n```scheme\n(char>=? #\\a #\\a) ; => #t\n(char>=? #\\b #\\a) ; => #t\n(char>=? #\\a #\\b) ; => #f\n```",
665 "line": 3780
666 },
667 {
668 "name": "char->integer",
669 "kind": "procedure",
670 "description": "Convert a character to its Unicode code point.\n\n```scheme\n(char->integer #\\a) ; => 97\n(char->integer #\\A) ; => 65\n(char->integer #\\λ) ; => 955\n(char->integer #\\space) ; => 32\n```",
671 "line": 3791
672 },
673 {
674 "name": "integer->char",
675 "kind": "procedure",
676 "description": "Convert a Unicode code point to its character.\n\n```scheme\n(integer->char 97) ; => #\\a\n(integer->char 65) ; => #\\A\n(integer->char 955) ; => #\\λ\n```",
677 "line": 3801
678 },
679 {
680 "name": "string",
681 "kind": "procedure",
682 "description": "Create a string from zero or more character arguments.\n\n```scheme\n(string #\\h #\\i) ; => \"hi\"\n(string) ; => \"\"\n(string #\\λ) ; => \"λ\"\n```",
683 "line": 3811
684 },
685 {
686 "name": "car",
687 "kind": "procedure",
688 "description": "Return the first element (car) of a pair.\n\n```scheme\n(car '(1 2 3)) ; => 1\n(car '(a . b)) ; => a\n(car '((1 2) 3 4)) ; => (1 2)\n```",
689 "line": 3825
690 },
691 {
692 "name": "cdr",
693 "kind": "procedure",
694 "description": "Return the rest (cdr) of a pair.\n\n```scheme\n(cdr '(1 2 3)) ; => (2 3)\n(cdr '(a . b)) ; => b\n(cdr '(1)) ; => ()\n```",
695 "line": 3835
696 },
697 {
698 "name": "cons",
699 "kind": "procedure",
700 "description": "Construct a new pair with the given car and cdr.\n\n```scheme\n(cons 1 2) ; => (1 . 2)\n(cons 1 '(2 3)) ; => (1 2 3)\n(cons 'a '()) ; => (a)\n```",
701 "line": 3845
702 },
703 {
704 "name": "set-car!",
705 "kind": "procedure",
706 "description": "Mutate the car of a pair.\n\n```scheme\n(define p (cons 1 2))\n(set-car! p 'a)\np ; => (a . 2)\n```",
707 "line": 3855
708 },
709 {
710 "name": "set-cdr!",
711 "kind": "procedure",
712 "description": "Mutate the cdr of a pair.\n\n```scheme\n(define p (cons 1 2))\n(set-cdr! p 'b)\np ; => (1 . b)\n```",
713 "line": 3865
714 },
715 {
716 "name": "vector-ref",
717 "kind": "procedure",
718 "description": "Return the element at position k in the vector.\n\n```scheme\n(vector-ref #(a b c) 0) ; => a\n(vector-ref #(a b c) 2) ; => c\n```\n\nThe index must be a non-negative integer less than the vector length.",
719 "line": 3880
720 },
721 {
722 "name": "vector-set!",
723 "kind": "procedure",
724 "description": "Set the element at position k in the vector.\n\n```scheme\n(define v #(1 2 3))\n(vector-set! v 1 'x)\nv ; => #(1 x 3)\n```",
725 "line": 3890
726 },
727 {
728 "name": "vector-length",
729 "kind": "procedure",
730 "description": "Return the number of elements in the vector.\n\n```scheme\n(vector-length #(a b c)) ; => 3\n(vector-length #()) ; => 0\n```",
731 "line": 3899
732 },
733 {
734 "name": "make-vector",
735 "kind": "procedure",
736 "description": "Create a vector of the given length, optionally filled with a value.\n\n```scheme\n(make-vector 3) ; => #(#<undefined> #<undefined> #<undefined>)\n(make-vector 3 'x) ; => #(x x x)\n(make-vector 0) ; => #()\n```",
737 "line": 3909
738 },
739 {
740 "name": "list->vector",
741 "kind": "procedure",
742 "description": "Convert a list to a freshly-allocated vector.\n\n```scheme\n(list->vector '(1 2 3)) ; => #(1 2 3)\n(list->vector '()) ; => #()\n```",
743 "line": 3918
744 },
745 {
746 "name": "vector->list",
747 "kind": "procedure",
748 "description": "Convert a vector, or a sub-range of it, to a list.\n\nWith one argument, converts the whole vector. `start` (default 0) and\n`end` (default the vector length) select the half-open range [start, end).\n\n```scheme\n(vector->list #(1 2 3)) ; => (1 2 3)\n(vector->list #(1 2 3) 1) ; => (2 3)\n(vector->list #(1 2 3 4) 1 3); => (2 3)\n```",
749 "line": 3931
750 },
751 {
752 "name": "vector-copy!",
753 "kind": "procedure",
754 "description": "Copy elements from one vector into another, in place.\n\nCopies the elements of `from` in the half-open range [start, end)\n(default the whole vector) into `to` starting at index `at`. Overlap is\nhandled correctly when `to` and `from` are the same vector.\n\n```scheme\n(define v #(1 2 3 4 5))\n(vector-copy! v 0 #(a b) 0 2)\nv ; => #(a b 3 4 5)\n```",
755 "line": 3945
756 },
757 {
758 "name": "vector-fill!",
759 "kind": "procedure",
760 "description": "Fill a vector, or a sub-range of it, with a value, in place.\n\n`start` (default 0) and `end` (default the vector length) select the\nhalf-open range [start, end) to fill.\n\n```scheme\n(define v #(1 2 3 4))\n(vector-fill! v 0) ; v => #(0 0 0 0)\n(vector-fill! v 9 1 3) ; v => #(0 9 9 0)\n```",
761 "line": 3958
762 },
763 {
764 "name": "vector-copy",
765 "kind": "procedure",
766 "description": "Copy a vector, optionally a sub-range.\n\n```scheme\n(vector-copy #(1 2 3)) ; => #(1 2 3)\n(vector-copy #(1 2 3) 1) ; => #(2 3)\n(vector-copy #(1 2 3) 0 2) ; => #(1 2)\n```",
767 "line": 3968
768 },
769 {
770 "name": "display",
771 "kind": "procedure",
772 "description": "Display a value to a port (default: current output port).\n\n```scheme\n(display \"hello\") ; prints: hello\n(display 42) ; prints: 42\n(display #\\newline) ; prints a newline\n```\n\nStrings are printed without quotes, characters without #\\ notation.",
773 "line": 3984
774 },
775 {
776 "name": "newline",
777 "kind": "procedure",
778 "description": "Write a newline to a port (default: current output port).\n\n```scheme\n(newline) ; prints a newline character\n```",
779 "line": 3992
780 },
781 {
782 "name": "write",
783 "kind": "procedure",
784 "description": "Write a value in machine-readable form to a port.\n\n```scheme\n(write \"hello\") ; prints: \"hello\"\n(write #\\a) ; prints: #\\a\n(write '(1 2)) ; prints: (1 2)\n```\n\nUnlike `display`, strings include quotes and characters include #\\ notation.",
785 "line": 4004
786 },
787 {
788 "name": "read-expr",
789 "kind": "procedure",
790 "description": "Read an S-expression from a string.\n\n```scheme\n(read-expr \"(+ 1 2)\") ; => (+ 1 2)\n(read-expr \"42\") ; => 42\n(read-expr \"\\\"hello\\\"\") ; => \"hello\"\n```",
791 "line": 4014
792 },
793 {
794 "name": "load",
795 "kind": "procedure",
796 "description": "Load and evaluate a Scheme source file.\n\n```scheme\n(load \"myfile.sgl\")\n```\n\nReads and evaluates all expressions in the file sequentially.",
797 "line": 4024
798 },
799 {
800 "name": "eval",
801 "kind": "procedure",
802 "description": "Evaluate an expression in the current environment.\n\n```scheme\n(eval '(+ 1 2)) ; => 3\n(eval '(list 'a 'b 'c)) ; => (a b c)\n```",
803 "line": 4033
804 },
805 {
806 "name": "symbol->string",
807 "kind": "procedure",
808 "description": "Convert a symbol to its string name.\n\n```scheme\n(symbol->string 'hello) ; => \"hello\"\n(symbol->string '+) ; => \"+\"\n```",
809 "line": 4046
810 },
811 {
812 "name": "string->symbol",
813 "kind": "procedure",
814 "description": "Convert a string to a symbol (interned).\n\n```scheme\n(string->symbol \"hello\") ; => hello\n(eq? (string->symbol \"x\") (string->symbol \"x\")) ; => #t\n```",
815 "line": 4055
816 },
817 {
818 "name": "number->string",
819 "kind": "procedure",
820 "description": "Convert a number to its string representation.\n\n```scheme\n(number->string 42) ; => \"42\"\n(number->string 3.14) ; => \"3.14\"\n(number->string 255 16) ; => \"ff\" (with radix)\n```",
821 "line": 4065
822 },
823 {
824 "name": "string->number",
825 "kind": "procedure",
826 "description": "Parse a string as a number, returning #f if invalid.\n\n```scheme\n(string->number \"42\") ; => 42\n(string->number \"3.14\") ; => 3.14\n(string->number \"ff\" 16) ; => 255 (with radix)\n(string->number \"abc\") ; => #f\n```",
827 "line": 4076
828 },
829 {
830 "name": "string->list",
831 "kind": "procedure",
832 "description": "Convert a string to a list of characters.\n\n```scheme\n(string->list \"hello\") ; => (#\\h #\\e #\\l #\\l #\\o)\n(string->list \"\") ; => ()\n```",
833 "line": 4085
834 },
835 {
836 "name": "list->string",
837 "kind": "procedure",
838 "description": "Convert a list of characters to a string.\n\n```scheme\n(list->string '(#\\h #\\i)) ; => \"hi\"\n(list->string '()) ; => \"\"\n```",
839 "line": 4094
840 },
841 {
842 "name": "string-copy",
843 "kind": "procedure",
844 "description": "Copy a string, optionally a sub-range.\n\n```scheme\n(string-copy \"hello\") ; => \"hello\"\n(string-copy \"hello\" 1) ; => \"ello\"\n(string-copy \"hello\" 1 4) ; => \"ell\"\n```",
845 "line": 4104
846 },
847 {
848 "name": "string-copy!",
849 "kind": "procedure",
850 "description": "Copy characters into an existing string, in place.\n\nCopies the characters of `from` in [start, end) (default the whole\nstring) into `to` starting at index `at`. Overlap is handled correctly\nwhen `to` and `from` are the same string. Each copied character must\nhave the same UTF-8 byte width as the character it replaces\n(width-changing writes raise an error, as with `string-set!`).\n\n```scheme\n(define s (string-copy \"hello\"))\n(string-copy! s 0 \"HE\" 0 2)\ns ; => \"HEllo\"\n```",
851 "line": 4120
852 },
853 {
854 "name": "string-fill!",
855 "kind": "procedure",
856 "description": "Fill a string range with a character, in place.\n\nFills str[start, end) (default the whole string) with `char`. The fill\ncharacter must have the same UTF-8 byte width as each character it\nreplaces (width-changing writes raise an error, as with `string-set!`).\n\n```scheme\n(define s (string-copy \"hello\"))\n(string-fill! s #\\x 1 3)\ns ; => \"hxxlo\"\n```",
857 "line": 4134
858 },
859 {
860 "name": "string-join",
861 "kind": "procedure",
862 "description": "Join a list of strings with an optional separator (default \"\").\n\nBuilds the result in a single pass.\n\n```scheme\n(string-join '(\"a\" \"b\" \"c\") \"-\") ; => \"a-b-c\"\n(string-join '(\"a\" \"b\" \"c\")) ; => \"abc\"\n(string-join '()) ; => \"\"\n```",
863 "line": 4146
864 },
865 {
866 "name": "string->vector",
867 "kind": "procedure",
868 "description": "Convert a string (optionally a sub-range) to a vector of characters.\n\nDecodes the string in a single O(n) pass. `start` (inclusive) and\n`end` (exclusive) are character indices.\n\n```scheme\n(string->vector \"abc\") ; => #(#\\a #\\b #\\c)\n(string->vector \"hello\" 1 4) ; => #(#\\e #\\l #\\l)\n```",
869 "line": 4158
870 },
871 {
872 "name": "vector->string",
873 "kind": "procedure",
874 "description": "Convert a vector of characters (optionally a sub-range) to a string.\n\n```scheme\n(vector->string #(#\\a #\\b #\\c)) ; => \"abc\"\n(vector->string #(#\\a #\\b #\\c) 1) ; => \"bc\"\n```",
875 "line": 4167
876 },
877 {
878 "name": "string->cursor",
879 "kind": "procedure",
880 "description": "Create a forward character cursor over a string.\n\nA cursor iterates a string's characters in O(1) amortized time per\nstep by tracking the byte offset alongside the character index —\nunlike indexed `string-ref`, which is O(index) on non-ASCII strings\nand makes per-char index loops O(n^2). Optional `start`/`end`\ncharacter indices restrict iteration to a sub-range without copying.\n\n```scheme\n(define cur (string->cursor \"hi\"))\n(cursor-peek cur) ; => #\\h (does not advance)\n(cursor-next! cur) ; => #\\h (advances)\n(cursor-next! cur) ; => #\\i\n(cursor-next! cur) ; => #f (end of string)\n(cursor-eof? cur) ; => #t\n```",
881 "line": 4186
882 },
883 {
884 "name": "string-cursor?",
885 "kind": "procedure",
886 "description": "Test whether a value is a string cursor.\n\n```scheme\n(string-cursor? (string->cursor \"x\")) ; => #t\n(string-cursor? \"x\") ; => #f\n```",
887 "line": 4195
888 },
889 {
890 "name": "cursor-peek",
891 "kind": "procedure",
892 "description": "Return the character at the cursor without advancing, or #f at end.\n\n```scheme\n(define cur (string->cursor \"ab\"))\n(cursor-peek cur) ; => #\\a\n(cursor-peek cur) ; => #\\a (unchanged)\n```",
893 "line": 4205
894 },
895 {
896 "name": "cursor-next!",
897 "kind": "procedure",
898 "description": "Return the character at the cursor and advance past it, or #f at end.\n\nThe lookahead-1 lexer pattern: `cursor-peek` to classify, then\n`cursor-next!` to consume.\n\n```scheme\n(define cur (string->cursor \"ab\"))\n(cursor-next! cur) ; => #\\a\n(cursor-next! cur) ; => #\\b\n(cursor-next! cur) ; => #f\n```",
899 "line": 4219
900 },
901 {
902 "name": "cursor-eof?",
903 "kind": "procedure",
904 "description": "Test whether a cursor has reached its end.\n\n```scheme\n(cursor-eof? (string->cursor \"\")) ; => #t\n(cursor-eof? (string->cursor \"a\")) ; => #f\n```",
905 "line": 4228
906 },
907 {
908 "name": "cursor-pos",
909 "kind": "procedure",
910 "description": "Return the cursor's current character index (absolute in the string).\n\n```scheme\n(define cur (string->cursor \"abc\"))\n(cursor-pos cur) ; => 0\n(cursor-next! cur)\n(cursor-pos cur) ; => 1\n```",
911 "line": 4239
912 },
913 {
914 "name": "bytevector?",
915 "kind": "procedure",
916 "description": "Test if a value is a bytevector.\n\n```scheme\n(bytevector? #u8(1 2 3)) ; => #t\n(bytevector? \"string\") ; => #f\n```",
917 "line": 4252
918 },
919 {
920 "name": "make-bytevector",
921 "kind": "procedure",
922 "description": "Create a bytevector of the given size, optionally filled with a byte value.\n\n```scheme\n(make-bytevector 3) ; => #u8(0 0 0)\n(make-bytevector 3 42) ; => #u8(42 42 42)\n```",
923 "line": 4261
924 },
925 {
926 "name": "bytevector-u8-ref",
927 "kind": "procedure",
928 "description": "Return the byte at position k in the bytevector.\n\n```scheme\n(bytevector-u8-ref #u8(10 20 30) 1) ; => 20\n```",
929 "line": 4269
930 },
931 {
932 "name": "bytevector-u8-set!",
933 "kind": "procedure",
934 "description": "Set the byte at position k in the bytevector.\n\n```scheme\n(define bv (make-bytevector 3 0))\n(bytevector-u8-set! bv 1 255)\nbv ; => #u8(0 255 0)\n```",
935 "line": 4279
936 },
937 {
938 "name": "bytevector-length",
939 "kind": "procedure",
940 "description": "Return the number of bytes in the bytevector.\n\n```scheme\n(bytevector-length #u8(1 2 3)) ; => 3\n```",
941 "line": 4287
942 },
943 {
944 "name": "bytevector",
945 "kind": "procedure",
946 "description": "Create a bytevector from byte arguments (each 0-255).\n\n```scheme\n(bytevector 1 2 3) ; => #u8(1 2 3)\n(bytevector) ; => #u8()\n```",
947 "line": 4296
948 },
949 {
950 "name": "bytevector-copy",
951 "kind": "procedure",
952 "description": "Copy a bytevector, optionally a sub-range.\n\n```scheme\n(bytevector-copy #u8(1 2 3)) ; => #u8(1 2 3)\n(bytevector-copy #u8(1 2 3) 1) ; => #u8(2 3)\n(bytevector-copy #u8(1 2 3) 0 2) ; => #u8(1 2)\n```",
953 "line": 4306
954 },
955 {
956 "name": "bytevector-copy!",
957 "kind": "procedure",
958 "description": "Copy bytes into an existing bytevector, in place.\n\nCopies the bytes of `from` in [start, end) (default the whole\nbytevector) into `to` starting at index `at`. Overlap is handled\ncorrectly when `to` and `from` are the same bytevector.\n\n```scheme\n(define bv (bytevector 1 2 3 4 5))\n(bytevector-copy! bv 0 #u8(9 9) 0 2)\nbv ; => #u8(9 9 3 4 5)\n```",
959 "line": 4320
960 },
961 {
962 "name": "bytevector-append",
963 "kind": "procedure",
964 "description": "Concatenate zero or more bytevectors.\n\n```scheme\n(bytevector-append #u8(1 2) #u8(3 4)) ; => #u8(1 2 3 4)\n(bytevector-append) ; => #u8()\n```",
965 "line": 4329
966 },
967 {
968 "name": "bytevector-ieee-double-ref",
969 "kind": "procedure",
970 "description": "Read an IEEE-754 double (8 bytes) at byte offset `k`.\n\nThe optional `endianness` is a symbol: `little`, `big`, or `native`\n(the default when omitted). The result is a flonum. Bounds-checked:\n`k + 8` must not exceed the bytevector length.\n\nA colliding NaN bit pattern read from arbitrary bytes is canonicalized\nto a safe quiet NaN (a Sigil-written value round-trips bit-exactly).\n\n```scheme\n(define bv (make-bytevector 8 0))\n(bytevector-ieee-double-set! bv 0 3.14 'little)\n(bytevector-ieee-double-ref bv 0 'little) ; => 3.14\n```",
971 "line": 4346
972 },
973 {
974 "name": "bytevector-ieee-double-set!",
975 "kind": "procedure",
976 "description": "Write an IEEE-754 double (8 bytes) at byte offset `k`.\n\nThe optional `endianness` is a symbol: `little`, `big`, or `native`\n(the default when omitted). Bounds-checked: `k + 8` must not exceed\nthe bytevector length.\n\n```scheme\n(define bv (make-bytevector 8 0))\n(bytevector-ieee-double-set! bv 0 -0.5) ; native endianness\n```",
977 "line": 4359
978 },
979 {
980 "name": "bytevector-ieee-single-ref",
981 "kind": "procedure",
982 "description": "Read an IEEE-754 single (4 bytes) at byte offset `k`, returned as a\nflonum (promoted to double precision).\n\nThe optional `endianness` is a symbol: `little`, `big`, or `native`\n(the default when omitted). Bounds-checked: `k + 4` must not exceed\nthe bytevector length.\n\n```scheme\n(define bv (make-bytevector 4 0))\n(bytevector-ieee-single-set! bv 0 1.5 'big)\n(bytevector-ieee-single-ref bv 0 'big) ; => 1.5\n```",
983 "line": 4374
984 },
985 {
986 "name": "bytevector-ieee-single-set!",
987 "kind": "procedure",
988 "description": "Write an IEEE-754 single (4 bytes) at byte offset `k`. The value is\nrounded to single precision.\n\nThe optional `endianness` is a symbol: `little`, `big`, or `native`\n(the default when omitted). Bounds-checked: `k + 4` must not exceed\nthe bytevector length.\n\n```scheme\n(define bv (make-bytevector 4 0))\n(bytevector-ieee-single-set! bv 0 2.0) ; native endianness\n```",
989 "line": 4388
990 },
991 {
992 "name": "srcloc?",
993 "kind": "procedure",
994 "description": "Test if a value is a source location object.",
995 "line": 4396
996 },
997 {
998 "name": "srcloc-file",
999 "kind": "procedure",
1000 "description": "Get the file path from a source location.",
1001 "line": 4400
1002 },
1004 "name": "srcloc-line",
1005 "kind": "procedure",
1006 "description": "Get the line number (1-based) from a source location.",
1007 "line": 4404
1008 },
1010 "name": "srcloc-column",
1011 "kind": "procedure",
1012 "description": "Get the column number (1-based) from a source location.",
1013 "line": 4408
1014 },
1016 "name": "srcloc-position",
1017 "kind": "procedure",
1018 "description": "Get the byte position from a source location.",
1019 "line": 4412
1020 },
1022 "name": "srcloc-span",
1023 "kind": "procedure",
1024 "description": "Get the byte span (length) from a source location.",
1025 "line": 4416
1026 },
1028 "name": "srcloc-origin",
1029 "kind": "procedure",
1030 "description": "Get the enclosing generated origin, or #f for manuscript locations.",
1031 "line": 4420
1032 },
1034 "name": "srcloc-origin-chain",
1035 "kind": "procedure",
1036 "description": "Return the generated-origin chain, authoritative manuscript first.",
1037 "line": 4424
1038 },
1040 "name": "srcloc-authoritative",
1041 "kind": "procedure",
1042 "description": "Return the authoritative manuscript source location.",
1043 "line": 4428
1044 },
1046 "name": "make-srcloc",
1047 "kind": "procedure",
1048 "description": "Create a source location object.\n\n```scheme\n(make-srcloc \"file.sgl\" 10 1 100 25)\n```\n\nArguments: file, line, column, position, span.",
1049 "line": 4438
1050 },
1052 "name": "make-generated-srcloc",
1053 "kind": "procedure",
1054 "description": "Create a generated source location linked to an enclosing origin.",
1055 "line": 4442
1056 },
1058 "name": "capture-stack-trace",
1059 "kind": "procedure",
1060 "description": "Capture the current call stack as a stack trace object.\n\n```scheme\n(capture-stack-trace 0) ; capture full stack\n(capture-stack-trace 1) ; skip 1 frame\n```",
1061 "line": 4455
1062 },
1064 "name": "stack-trace?",
1065 "kind": "procedure",
1066 "description": "Test if a value is a stack trace object.",
1067 "line": 4459
1068 },
1070 "name": "stack-trace-length",
1071 "kind": "procedure",
1072 "description": "Return the number of frames in a stack trace.",
1073 "line": 4463
1074 },
1076 "name": "stack-trace-ref",
1077 "kind": "procedure",
1078 "description": "Get a frame from a stack trace as a vector.\n\nReturns #(proc-name srcloc) or #f if index is out of bounds.",
1079 "line": 4469
1080 },
1082 "name": "foreign?",
1083 "kind": "procedure",
1084 "description": "Test if a value is a foreign (C) object.",
1085 "line": 4477
1086 },
1088 "name": "foreign-type",
1089 "kind": "procedure",
1090 "description": "Get the type tag of a foreign object.",
1091 "line": 4481
1092 },
1094 "name": "+",
1095 "kind": "procedure",
1096 "description": "Add zero or more numbers.\n\n```scheme\n(+) ; => 0\n(+ 1) ; => 1\n(+ 1 2 3) ; => 6\n(+ 1.5 2.5) ; => 4.0\n```",
1097 "line": 4496
1098 },
1100 "name": "-",
1101 "kind": "procedure",
1102 "description": "Subtract numbers or negate a single number.\n\n```scheme\n(- 5) ; => -5 (negation)\n(- 5 3) ; => 2\n(- 10 3 2) ; => 5\n```",
1103 "line": 4506
1104 },
1106 "name": "*",
1107 "kind": "procedure",
1108 "description": "Multiply zero or more numbers.\n\n```scheme\n(*) ; => 1\n(* 2) ; => 2\n(* 2 3 4) ; => 24\n```",
1109 "line": 4516
1110 },
1112 "name": "/",
1113 "kind": "procedure",
1114 "description": "Divide numbers or compute reciprocal.\n\n```scheme\n(/ 2) ; => 0.5 (reciprocal)\n(/ 10 2) ; => 5\n(/ 24 2 3) ; => 4\n```",
1115 "line": 4526
1116 },
1118 "name": "<",
1119 "kind": "procedure",
1120 "description": "Test if arguments are in strictly increasing order.\n\n```scheme\n(< 1 2) ; => #t\n(< 1 2 3) ; => #t\n(< 1 1) ; => #f\n```",
1121 "line": 4536
1122 },
1124 "name": ">",
1125 "kind": "procedure",
1126 "description": "Test if arguments are in strictly decreasing order.\n\n```scheme\n(> 2 1) ; => #t\n(> 3 2 1) ; => #t\n(> 1 1) ; => #f\n```",
1127 "line": 4546
1128 },
1130 "name": "<=",
1131 "kind": "procedure",
1132 "description": "Test if arguments are in non-decreasing order.\n\n```scheme\n(<= 1 2) ; => #t\n(<= 1 1) ; => #t\n(<= 2 1) ; => #f\n```",
1133 "line": 4556
1134 },
1136 "name": ">=",
1137 "kind": "procedure",
1138 "description": "Test if arguments are in non-increasing order.\n\n```scheme\n(>= 2 1) ; => #t\n(>= 1 1) ; => #t\n(>= 1 2) ; => #f\n```",
1139 "line": 4566
1140 },
1142 "name": "=",
1143 "kind": "procedure",
1144 "description": "Test if all arguments are numerically equal.\n\n```scheme\n(= 1 1) ; => #t\n(= 1 1 1) ; => #t\n(= 1 2) ; => #f\n(= 1 1.0) ; => #t\n```",
1145 "line": 4577
1146 },
1148 "name": "null?",
1149 "kind": "procedure",
1150 "description": "Test if a value is the empty list.\n\n```scheme\n(null? '()) ; => #t\n(null? '(1)) ; => #f\n```",
1151 "line": 4590
1152 },
1154 "name": "pair?",
1155 "kind": "procedure",
1156 "description": "Test if a value is a pair.\n\n```scheme\n(pair? '(1 . 2)) ; => #t\n(pair? '(1 2)) ; => #t\n(pair? '()) ; => #f\n```",
1157 "line": 4600
1158 },
1160 "name": "number?",
1161 "kind": "procedure",
1162 "description": "Test if a value is a number.\n\n```scheme\n(number? 42) ; => #t\n(number? 3.14) ; => #t\n(number? \"42\") ; => #f\n```",
1163 "line": 4610
1164 },
1166 "name": "symbol?",
1167 "kind": "procedure",
1168 "description": "Test if a value is a symbol.\n\n```scheme\n(symbol? 'foo) ; => #t\n(symbol? \"foo\") ; => #f\n```",
1169 "line": 4619
1170 },
1172 "name": "string?",
1173 "kind": "procedure",
1174 "description": "Test if a value is a string.\n\n```scheme\n(string? \"hello\") ; => #t\n(string? 'hello) ; => #f\n```",
1175 "line": 4628
1176 },
1178 "name": "vector?",
1179 "kind": "procedure",
1180 "description": "Test if a value is a vector.\n\n```scheme\n(vector? #(1 2 3)) ; => #t\n(vector? '(1 2 3)) ; => #f\n```",
1181 "line": 4637
1182 },
1184 "name": "procedure?",
1185 "kind": "procedure",
1186 "description": "Test if a value is a procedure.\n\n```scheme\n(procedure? +) ; => #t\n(procedure? (lambda (x) x)) ; => #t\n(procedure? 42) ; => #f\n```",
1187 "line": 4647
1188 },
1190 "name": "boolean?",
1191 "kind": "procedure",
1192 "description": "Test if a value is a boolean.\n\n```scheme\n(boolean? #t) ; => #t\n(boolean? #f) ; => #t\n(boolean? 0) ; => #f\n```",
1193 "line": 4657
1194 },
1196 "name": "char?",
1197 "kind": "procedure",
1198 "description": "Test if a value is a character.\n\n```scheme\n(char? #\\a) ; => #t\n(char? \"a\") ; => #f\n```",
1199 "line": 4666
1200 },
1202 "name": "list?",
1203 "kind": "procedure",
1204 "description": "Test if a value is a proper list.\n\n```scheme\n(list? '(1 2 3)) ; => #t\n(list? '()) ; => #t\n(list? '(1 . 2)) ; => #f (improper list)\n```",
1205 "line": 4676
1206 },
1208 "name": "list",
1209 "kind": "procedure",
1210 "description": "Create a list from the arguments.\n\n```scheme\n(list 1 2 3) ; => (1 2 3)\n(list) ; => ()\n(list 'a 'b) ; => (a b)\n```",
1211 "line": 4686
1212 },
1214 "name": "length",
1215 "kind": "procedure",
1216 "description": "Return the length of a list.\n\n```scheme\n(length '(1 2 3)) ; => 3\n(length '()) ; => 0\n```",
1217 "line": 4695
1218 },
1220 "name": "integer?",
1221 "kind": "procedure",
1222 "description": "Test if a value is an exact integer.\n\n```scheme\n(integer? 42) ; => #t\n(integer? 3.0) ; => #f\n(integer? 3.5) ; => #f\n```",
1223 "line": 4705
1224 },
1226 "name": "eof-object?",
1227 "kind": "procedure",
1228 "description": "Test if a value is the end-of-file object.\n\n```scheme\n(eof-object? (eof-object)) ; => #t\n(eof-object? #f) ; => #f\n```",
1229 "line": 4714
1230 },
1232 "name": "eq?",
1233 "kind": "procedure",
1234 "description": "Test object identity (same memory location).\n\n```scheme\n(eq? 'a 'a) ; => #t\n(eq? '() '()) ; => #t\n(eq? \"a\" \"a\") ; => unspecified\n(define x '(1 2))\n(eq? x x) ; => #t\n```",
1235 "line": 4726
1236 },
1238 "name": "eqv?",
1239 "kind": "procedure",
1240 "description": "Test equivalence (same type and value).\n\n```scheme\n(eqv? 1 1) ; => #t\n(eqv? 1 1.0) ; => #f\n(eqv? #\\a #\\a) ; => #t\n```",
1241 "line": 4736
1242 },
1244 "name": "equal?",
1245 "kind": "procedure",
1246 "description": "Test structural equality (deep comparison).\n\n```scheme\n(equal? '(1 2 3) '(1 2 3)) ; => #t\n(equal? \"hello\" \"hello\") ; => #t\n(equal? #(1 2) #(1 2)) ; => #t\n```",
1247 "line": 4746
1248 },
1250 "name": "not",
1251 "kind": "procedure",
1252 "description": "Boolean negation.\n\n```scheme\n(not #f) ; => #t\n(not #t) ; => #f\n(not '()) ; => #f (only #f is false)\n(not 0) ; => #f\n```",
1253 "line": 4757
1254 },
1256 "name": "gensym",
1257 "kind": "procedure",
1258 "description": "Generate a unique symbol, optionally with a prefix.\n\n```scheme\n(gensym) ; => g1234 (unique each time)\n(gensym \"temp\") ; => temp1235\n```",
1259 "line": 4770
1260 },
1262 "name": "apply",
1263 "kind": "procedure",
1264 "description": "Apply a procedure to a list of arguments.\n\n```scheme\n(apply + '(1 2 3)) ; => 6\n(apply list 'a 'b '(c d)) ; => (a b c d)\n```",
1265 "line": 4779
1266 },
1268 "name": "values",
1269 "kind": "procedure",
1270 "description": "Return multiple values.\n\n```scheme\n(values 1 2 3) ; returns 3 values\n(call-with-values (lambda () (values 1 2))\n (lambda (a b) (+ a b))) ; => 3\n```",
1271 "line": 4789
1272 },
1274 "name": "call-with-values",
1275 "kind": "procedure",
1276 "description": "Call producer with no args, pass its values to consumer.\n\n```scheme\n(call-with-values\n (lambda () (values 1 2))\n (lambda (a b) (+ a b))) ; => 3\n```",
1277 "line": 4799
1278 },
1280 "name": "make-parameter",
1281 "kind": "procedure",
1282 "description": "Create a parameter object (dynamic variable).\n\n```scheme\n(define my-param (make-parameter 10))\n(my-param) ; => 10\n(my-param 20) ; set to 20\n(my-param) ; => 20\n```",
1283 "line": 4810
1284 },
1286 "name": "parameter?",
1287 "kind": "procedure",
1288 "description": "Test if a value is a parameter object.",
1289 "line": 4814
1290 },
1292 "name": "promise?",
1293 "kind": "procedure",
1294 "description": "Test if a value is a promise.\n\n```scheme\n(promise? (delay (+ 1 2))) ; => #t\n(promise? 42) ; => #f\n```",
1295 "line": 4827
1296 },
1298 "name": "make-promise",
1299 "kind": "procedure",
1300 "description": "Create an already-forced promise containing a value.\n\n```scheme\n(force (make-promise 42)) ; => 42\n```",
1301 "line": 4835
1302 },
1304 "name": "force",
1305 "kind": "procedure",
1306 "description": "Force evaluation of a promise, caching the result.\n\n```scheme\n(define p (delay (begin (display \"computing...\") (+ 1 2))))\n(force p) ; prints \"computing...\", returns 3\n(force p) ; returns 3 (cached, no print)\n```",
1307 "line": 4845
1308 },
1310 "name": "eval-string",
1311 "kind": "procedure",
1312 "description": "Evaluate a string as Sigil code.\n\n```scheme\n(eval-string \"(+ 1 2)\") ; => 3\n```",
1313 "line": 4857
1314 },
1316 "name": "eval-string-in-module",
1317 "kind": "procedure",
1318 "description": "Evaluate a string in a specific module's context.\n\n```scheme\n(eval-string-in-module \"(+ 1 2)\" (find-module '(sigil core)))\n```",
1319 "line": 4865
1320 },
1322 "name": "procedure-metadata",
1323 "kind": "procedure",
1324 "description": "Get the metadata alist of a procedure.\n\n```scheme\n(procedure-metadata my-proc) ; => ((doc . \"...\") (name . my-proc))\n```",
1325 "line": 4877
1326 },
1328 "name": "set-procedure-metadata!",
1329 "kind": "procedure",
1330 "description": "Set the metadata alist of a procedure.\n\n```scheme\n(set-procedure-metadata! my-proc '((custom . value)))\n```",
1331 "line": 4885
1332 },
1334 "name": "procedure-module",
1335 "kind": "procedure",
1336 "description": "Get the module a procedure was defined in.",
1337 "line": 4889
1338 },
1340 "name": "set-procedure-module!",
1341 "kind": "procedure",
1342 "description": "Set the module attribution of a procedure.",
1343 "line": 4893
1344 },
1346 "name": "procedure-arity",
1347 "kind": "procedure",
1348 "description": "Get the arity specification of a procedure.\n\n```scheme\n(procedure-arity +) ; => (-1 . 0) (variadic, at least 0 args)\n```",
1349 "line": 4901
1350 },
1352 "name": "procedure-name",
1353 "kind": "procedure",
1354 "description": "Get the name of a procedure (symbol or #f).\n\n```scheme\n(procedure-name car) ; => car\n```",
1355 "line": 4909
1356 },
1358 "name": "module?",
1359 "kind": "procedure",
1360 "description": "Test if a value is a module.",
1361 "line": 4917
1362 },
1364 "name": "current-module",
1365 "kind": "procedure",
1366 "description": "Get the current module context.",
1367 "line": 4921
1368 },
1370 "name": "set-current-module!",
1371 "kind": "procedure",
1372 "description": "Set the current module context.",
1373 "line": 4925
1374 },
1376 "name": "macroexpand",
1377 "kind": "procedure",
1378 "description": "Expand macros in an expression (for debugging).\n\n```scheme\n(macroexpand '(when #t (display \"hi\")))\n```",
1379 "line": 4933
1380 },
1382 "name": "disassemble",
1383 "kind": "procedure",
1384 "description": "Disassemble a procedure's bytecode (for debugging).\n\n```scheme\n(disassemble my-proc)\n```",
1385 "line": 4941
1386 },
1388 "name": "find-module",
1389 "kind": "procedure",
1390 "description": "Find a module by its name, returning #f if not loaded.\n\n```scheme\n(find-module '(sigil core)) ; => #<module (sigil core)>\n```",
1391 "line": 4949
1392 },
1394 "name": "load-module",
1395 "kind": "procedure",
1396 "description": "Load a module by name, returning the module object.\n\n```scheme\n(load-module '(sigil json)) ; => #<module (sigil json)>\n```",
1397 "line": 4957
1398 },
1400 "name": "module-exports",
1401 "kind": "procedure",
1402 "description": "Get the list of exported symbols from a module.\n\n```scheme\n(module-exports (find-module '(sigil path))) ; => (path-join path-dirname ...)\n```",
1403 "line": 4965
1404 },
1406 "name": "module-ref",
1407 "kind": "procedure",
1408 "description": "Look up a binding in a module by name.\n\n```scheme\n(module-ref (find-module '(sigil core)) 'car) ; => #<native car>\n```",
1409 "line": 4973
1410 },
1412 "name": "module-name",
1413 "kind": "procedure",
1414 "description": "Get the name of a module as a list of symbols.\n\n```scheme\n(module-name (current-module)) ; => (sigil user)\n```",
1415 "line": 4981
1416 },
1418 "name": "add-library-path!",
1419 "kind": "procedure",
1420 "description": "Add a directory to the library search path.\n\n```scheme\n(add-library-path! \"/my/modules\")\n```",
1421 "line": 4989
1422 },
1424 "name": "%add-summary-path!",
1425 "kind": "procedure",
1426 "description": "Register a compiler-owned output/cache directory as eligible for cross-CU\noptimizer summaries. Source directories must never be registered here.",
1427 "line": 4994
1428 },
1430 "name": "library-paths",
1431 "kind": "procedure",
1432 "description": "Return the list of library search paths.\n\n```scheme\n(library-paths) ; => (\"/usr/lib/sigil\" \"/home/user/lib\")\n```",
1433 "line": 5002
1434 },
1436 "name": "current-milliseconds",
1437 "kind": "procedure",
1438 "description": "Get the current time in milliseconds since epoch.\n\n```scheme\n(current-milliseconds) ; => 1702834567890\n```",
1439 "line": 5014
1440 },
1442 "name": "keyword?",
1443 "kind": "procedure",
1444 "description": "Test if a value is a keyword.\n\n```scheme\n(keyword? foo:) ; => #t\n(keyword? 'foo) ; => #f\n```",
1445 "line": 5027
1446 },
1448 "name": "keyword->string",
1449 "kind": "procedure",
1450 "description": "Convert a keyword to a string (without the colon).\n\n```scheme\n(keyword->string foo:) ; => \"foo\"\n```",
1451 "line": 5035
1452 },
1454 "name": "string->keyword",
1455 "kind": "procedure",
1456 "description": "Convert a string to a keyword.\n\n```scheme\n(string->keyword \"foo\") ; => foo:\n```",
1457 "line": 5043
1458 },
1460 "name": "keyword->symbol",
1461 "kind": "procedure",
1462 "description": "Convert a keyword to a symbol.\n\n```scheme\n(keyword->symbol foo:) ; => foo\n```",
1463 "line": 5051
1464 },
1466 "name": "split-keyword-args",
1467 "kind": "procedure",
1468 "description": "Split an argument list into positional and keyword arguments\nReturns (positional-args . keyword-alist)\nwhere keyword-alist is ((kw . value) ...)",
1469 "line": 5062
1470 },
1472 "name": "keyword-ref",
1473 "kind": "procedure",
1474 "description": "Get a keyword value from a keyword alist\nReturns default if keyword not found",
1475 "line": 5081
1476 },
1478 "name": "keyword-check-unknown",
1479 "kind": "procedure",
1480 "description": "Check for unknown keywords and signal error if any found\nknown-keywords is a list of keyword objects",
1481 "line": 5090
1482 },
1484 "name": "keys-form?",
1485 "kind": "procedure",
1486 "description": "Usage:\n (lambda ((keys: x (y 10)))\n (+ x y))\n\n (define (add (keys: (x 0) (y 0)))\n (+ x y))\n\n (add x: 1 y: 2) ; => 3\n (add x: 5) ; => 5 (y defaults to 0)\n\nThe (keys: ...) form contains keyword parameter specs:\n name - required keyword (no default)\n (name default) - optional keyword with default value\n\nWhen no (keys: ...) form is present, lambda/define work normally.\nHelper: Check if a form is (keys: ...)",
1487 "line": 5123
1488 },
1490 "name": "opts-form?",
1491 "kind": "procedure",
1492 "description": "Helper: Check if a form is (opts: ...)",
1493 "line": 5129
1494 },
1496 "name": "rest-form?",
1497 "kind": "procedure",
1498 "description": "Helper: Check if a form is (rest: ...)",
1499 "line": 5135
1500 },
1502 "name": "special-form-param?",
1503 "kind": "procedure",
1504 "description": "Helper: Check if a form is any special parameter form",
1505 "line": 5141
1506 },
1508 "name": "parse-key-specs",
1509 "kind": "procedure",
1510 "description": "Helper: Parse keyword parameter specs from (keys: spec ...)\nReturns list of (name has-default default-expr keyword-obj)",
1511 "line": 5146
1512 },
1514 "name": "parse-opt-specs",
1515 "kind": "procedure",
1516 "description": "Helper: Parse optional positional parameter specs from (opts: spec ...)\nReturns list of (name default-expr)",
1517 "line": 5159
1518 },
1520 "name": "extract-positional-params",
1521 "kind": "procedure",
1522 "description": "Helper: Extract required positional params (everything before opts:/keys:/rest:)",
1523 "line": 5168
1524 },
1526 "name": "extract-keys-form",
1527 "kind": "procedure",
1528 "description": "Helper: Find and extract the (keys: ...) form from formals",
1529 "line": 5176
1530 },
1532 "name": "extract-opts-form",
1533 "kind": "procedure",
1534 "description": "Helper: Find and extract the (opts: ...) form from formals",
1535 "line": 5184
1536 },
1538 "name": "extract-rest-form",
1539 "kind": "procedure",
1540 "description": "Helper: Find and extract the (rest: ...) form from formals",
1541 "line": 5192
1542 },
1544 "name": "build-keyword-let-bindings",
1545 "kind": "procedure",
1546 "description": "Helper: Build let bindings for keyword parameters\nparsed-specs: ((name has-default default kw-obj) ...)",
1547 "line": 5201
1548 },
1550 "name": "build-required-bindings",
1551 "kind": "procedure",
1552 "description": "Helper: Build let bindings to extract required positional params\nReturns (bindings . rest-var-name) where rest-var-name is the variable\nholding remaining args after required params are extracted",
1553 "line": 5227
1554 },
1556 "name": "build-optional-bindings",
1557 "kind": "procedure",
1558 "description": "Helper: Build let bindings for optional positional params\nopt-specs: ((name default) ...)\nReturns (bindings . rest-var-name)",
1559 "line": 5249
1560 },
1562 "name": "any-of",
1563 "kind": "procedure",
1564 "description": "Return a predicate accepting values satisfying any of the given predicates.\n\n```scheme\n((any-of string? number?) \"hi\") ; => #t\n((any-of string? number?) 42) ; => #t\n((any-of string? number?) #t) ; => #f\n```",
1565 "line": 5314
1566 },
1568 "name": "maybe",
1569 "kind": "procedure",
1570 "description": "Return a predicate accepting #f or values satisfying pred.\n\n```scheme\n((maybe string?) \"hi\") ; => #t\n((maybe string?) #f) ; => #t\n((maybe string?) 42) ; => #f\n```",
1571 "line": 5325
1572 },
1574 "name": "list-of",
1575 "kind": "procedure",
1576 "description": "Return a predicate accepting lists where every element satisfies pred.\n\n```scheme\n((list-of number?) '(1 2 3)) ; => #t\n((list-of number?) '(1 \"a\" 3)) ; => #f\n((list-of number?) '()) ; => #t\n```",
1577 "line": 5336
1578 },
1580 "name": "none-of",
1581 "kind": "procedure",
1582 "description": "Return a predicate rejecting values that satisfy any of the given predicates.\n\n```scheme\n((none-of string? number?) #t) ; => #t\n((none-of string? number?) \"hi\") ; => #f\n((none-of string? number?) 42) ; => #f\n```",
1583 "line": 5347
1584 },
1586 "name": "any?",
1587 "kind": "procedure",
1588 "description": "Always-true predicate for \"any type\" in specs.",
1589 "line": 5352
1590 },
1592 "name": "lambda-transformer",
1593 "kind": "procedure",
1594 "description": "lambda-transformer - The core implementation for extended lambda\nUsed by both 'lambda' and 'fn' macros.\nSupports extended parameter forms:\n (opts: (name default) ...) - optional positional parameters\n (keys: name (name default) ...) - keyword parameters\n (rest: name) - rest parameter for remaining positional args\nIf no special forms, expands to plain %lambda.",
1595 "line": 5449
1596 },
1598 "name": "define-transformer",
1599 "kind": "procedure",
1600 "description": "define-transformer - Extended define with function shorthand and keyword support\n\nHandles both simple definitions and function shorthand:\n (define x 42) => (%define x 42)\n (define (f x) body...) => (%define (f x) body...)\n (define (f x (opts: ...)) body...) => (%define f (lambda ...))\n\nSimple function shorthand is preserved so the C compiler can apply docstrings.\nExtended parameter syntax (opts:, keys:, rest:) requires lambda conversion.\nThe input form's docstring is propagated to the output for doc attachment.",
1601 "line": 5573
1602 },
1604 "name": "procedure-spec",
1605 "kind": "procedure",
1606 "description": "Get the spec annotation from a procedure, or #f if none.\n\nReturns the spec list from a procedure's metadata, or #f if the\nprocedure has no spec annotation.\n\n```scheme\n(define (add a b)\n (: number? number? -> number?)\n (+ a b))\n(procedure-spec add) ; => (number? number? -> number?)\n```",
1607 "line": 5643