ref: f4eca39822c7c76bd36b15dcfaf2a8641cffa9f5
parent: 4fcc2a33709dcf462db4d03b44b0d412d692ec82
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sat May 24 22:48:07 EDT 2025
document io-close
--- a/boot/sl.boot
+++ b/boot/sl.boot
@@ -14,7 +14,7 @@
NIL NIL NIL NIL NIL #fn("z0700}2:" #(aref) 6) NIL)
*properties* #table(*formals-list* #table(append (lists) io-eof? ((io)) path-exists? ((path)) cadddr ((lst)) sort ((lst
less-than? (:key identity))) fixnum? ((v)) exit (((status NIL))) __finish ((status)) caaar ((lst)) s32 (((n
-0))) u8 (((n 0))) any ((pred lst)) nthcdr ((lst n)) os-getenv ((name)) s8 (((n 0))) num? ((v)) assert ((expr)) vec->list ((vc)) 1+ ((n)) throw ((tag
+0))) u8 (((n 0))) any ((pred lst)) nthcdr ((lst n)) os-getenv ((name)) s8 (((n 0))) io-close ((io)) num? ((v)) assert ((expr)) vec->list ((vc)) 1+ ((n)) throw ((tag
value)) positive? ((n)) atan ((x) (y x)) remprop ((symbol key)) delete-file ((path)) cdddar ((lst)) set-cdr! ((cell
new-second)) stacktrace (NIL) eq? ((a b)) io->str ((io)) bound? ((sym)) list->vec ((lst)) def ((form
body₀ . rest)
@@ -66,7 +66,7 @@
nbits)) str-sub ((s start (end NIL))) cddadr ((lst)) memv ((item lst)) max ((v . rest)) closure? ((v)) read-all ((io)) rand-f64 (NIL) help-print-header ((term
sigs (:kind NIL) (:lpad ""))) sleep ((sec)) s16 (((n 0))) rune? ((v)) os-setenv ((name value)) __script ((path))) *doc* #table(append "Return the concatenation of the arguments.\n\nLists are copied, except the last one, which becomes the `cdr` of the\nfinal dotted pair. It's returned as is if it was the only argument.\nNo lists are changed in-place.\n\nExamples:\n\n (append '(1) '(2 3) '(4))\n ; ↳ (1 2 3 4)\n\n (append '(1))\n ; ↳ (1)" (doc
group error) "Errors and exception handling." io-eof? "Return `T` if `io` is currently in the \"end of file\" state, `NIL`\notherwise." path-exists? "Return `T` if `path` exists on the filesystem, `NIL` otherwise." cadddr "Shorthand for (car (cdr (cdr (cdr lst))))." (doc
-group string) "Strings and runes." sort "Return a copy of the list sorted by comparing elements with the\ntwo-argument function `less-than?`.\n\nAn optional keyworded argument `:key` is used to provide a function to\nretrieve terms (the _key_) from the list items in order to perform\ncomparison. By default the terms compared are the list elements\nthemselves.\n\nExamples:\n\n ; simple sort (note: symbols > numbers)\n (sort '(1a 1 0 2b e 3) <)\n ; ↳ (0 1 3 1a 2b e)\n\n ; sort in lexicographical order (as strings)\n (sort '(1a 1 0 2b e 3) < :key str)\n ; ↳ (0 1 1a 2b 3 e)\n\n ; sort by type (note how the numbers stayed in the same order)\n (sort '(3 \"a\" 1 a #\\a 2)\n (λ (a b) (< (type-of a) (type-of b))))\n ; ↳ (3 1 2 #\\a \"a\" a)" fixnum? "Return `T` if `v` is of a fixnum type, `NIL` otherwise." exit "Terminate the process with the specified status. Does not return.\nThe status is expected to be a string in case of an error.\n\nExamples:\n\n (exit) ; exit with status 0 (nil on Plan 9)\n (exit \"error\") ; exit with status 1 (\"error\" on Plan 9)" __finish "A function called right before exit by the VM.\n\nThe exit `status` is either `NIL` or a string referring to an error\ncondition." caaar "Shorthand for (car (car (car lst)))." s32 "Construct a 32-bit signed number." u8 "Construct a 8-bit unsigned number." any "Return `T` if the predicate is true for _any_ element of the list,\n`NIL` otherwise.\n\nExample:\n\n ; is there any even number?\n (any even? '(1 3 5 7))\n ; ↳ NIL\n\n ; is there any string longer than one rune?\n (any (λ (s) (length> s 1))\n '(\"ab\" \"cd\" \"e\"))\n ; ↳ T" nthcdr "Return the reminder of the list after at most `n` elements, or `NIL`\nif the list is shorter.\n\nExamples:\n\n (def l '(a b c))\n (nthcdr l 1)\n ; ↳ (b c)\n (nthcdr l 2)\n ; ↳ (c)\n (nthcdr l 10)\n ; ↳ NIL" os-getenv "Return the value of the environment variable `name` or `NIL` if it's\nnot set." s8 "Construct a 8-bit signed number." num? "Return `T` if `v` is of a numerical type, `NIL` otherwise.\n\nNumerical types include floating point, fixnum, bignum, etc.\nNote: ironically, a NaN value is considered a number by this function\nsince it's only testing the _type_ of the value." assert "Throw an exception if `expr` evaluates to `NIL`. Return `T` in any\nother case.\n\nExamples:\n\n (def s \"abc\")\n (assert (= (length s) 3))\n ; ↳ T\n (assert (eq? (str-rune s 0) #\\x))\n ; ‼ assertion failed: ..." vec->list "Return the vector converted to a list.\n\nExamples:\n\n (vec->list #(1 2 a))\n ; ↳ (1 2 a)" 1+ "Equivalent to `(+ n 1)` - increment by one." throw "Raise an exception consisting of a tag and a value.\n\nThis exception can be caught by `catch`." positive? "Return `T` if `n` is greater than zero. Shorthand for `(> n 0)`." atan "Return the arc tangent of `y/x` in radians." *builtins* "VM instructions as closures." remprop "Remove a property value associated with the symbol." (doc
+group string) "Strings and runes." sort "Return a copy of the list sorted by comparing elements with the\ntwo-argument function `less-than?`.\n\nAn optional keyworded argument `:key` is used to provide a function to\nretrieve terms (the _key_) from the list items in order to perform\ncomparison. By default the terms compared are the list elements\nthemselves.\n\nExamples:\n\n ; simple sort (note: symbols > numbers)\n (sort '(1a 1 0 2b e 3) <)\n ; ↳ (0 1 3 1a 2b e)\n\n ; sort in lexicographical order (as strings)\n (sort '(1a 1 0 2b e 3) < :key str)\n ; ↳ (0 1 1a 2b 3 e)\n\n ; sort by type (note how the numbers stayed in the same order)\n (sort '(3 \"a\" 1 a #\\a 2)\n (λ (a b) (< (type-of a) (type-of b))))\n ; ↳ (3 1 2 #\\a \"a\" a)" fixnum? "Return `T` if `v` is of a fixnum type, `NIL` otherwise." exit "Terminate the process with the specified status. Does not return.\nThe status is expected to be a string in case of an error.\n\nExamples:\n\n (exit) ; exit with status 0 (nil on Plan 9)\n (exit \"error\") ; exit with status 1 (\"error\" on Plan 9)" __finish "A function called right before exit by the VM.\n\nThe exit `status` is either `NIL` or a string referring to an error\ncondition." caaar "Shorthand for (car (car (car lst)))." s32 "Construct a 32-bit signed number." u8 "Construct a 8-bit unsigned number." any "Return `T` if the predicate is true for _any_ element of the list,\n`NIL` otherwise.\n\nExample:\n\n ; is there any even number?\n (any even? '(1 3 5 7))\n ; ↳ NIL\n\n ; is there any string longer than one rune?\n (any (λ (s) (length> s 1))\n '(\"ab\" \"cd\" \"e\"))\n ; ↳ T" nthcdr "Return the reminder of the list after at most `n` elements, or `NIL`\nif the list is shorter.\n\nExamples:\n\n (def l '(a b c))\n (nthcdr l 1)\n ; ↳ (b c)\n (nthcdr l 2)\n ; ↳ (c)\n (nthcdr l 10)\n ; ↳ NIL" os-getenv "Return the value of the environment variable `name` or `NIL` if it's\nnot set." s8 "Construct a 8-bit signed number." io-close "Close the IO object.\n\nNo further operations on the IO object are possible, those will throw\nan exception if attempted. The only exception is `(io-filename io)`,\nwhich might be useful in some cases for debugging purposes.\n\nExamples:\n\n (def f (file \"/dev/random\"))\n (io-read f 'u8)\n ; ↳ #u8(123)\n (io-close f)\n (io-read f 'u8)\n ; ‼ I/O error: closed file" num? "Return `T` if `v` is of a numerical type, `NIL` otherwise.\n\nNumerical types include floating point, fixnum, bignum, etc.\nNote: ironically, a NaN value is considered a number by this function\nsince it's only testing the _type_ of the value." assert "Throw an exception if `expr` evaluates to `NIL`. Return `T` in any\nother case.\n\nExamples:\n\n (def s \"abc\")\n (assert (= (length s) 3))\n ; ↳ T\n (assert (eq? (str-rune s 0) #\\x))\n ; ‼ assertion failed: ..." vec->list "Return the vector converted to a list.\n\nExamples:\n\n (vec->list #(1 2 a))\n ; ↳ (1 2 a)" 1+ "Equivalent to `(+ n 1)` - increment by one." throw "Raise an exception consisting of a tag and a value.\n\nThis exception can be caught by `catch`." positive? "Return `T` if `n` is greater than zero. Shorthand for `(> n 0)`." atan "Return the arc tangent of `y/x` in radians." *builtins* "VM instructions as closures." remprop "Remove a property value associated with the symbol." (doc
group list) "Working with lists." delete-file "Delete the file from the filesystem.\n\nThrows an IO error if file does not exist or it failed to be deleted." (doc
group compare) "Comparison operators." cdddar "Shorthand for (cdr (cdr (cdr (car lst))))." set-cdr! "Modify a cons cell (a list) in-place by putting `new-second` as its\nsecond element (tail of the list). Return the modified cons\ncell (list).\n\nExamples:\n\n (def q '(1 2 3 4 5))\n (set-cdr! q '(6 7))\n ; ↳ (1 6 7)\n q\n ; ↳ (1 6 7)" stacktrace "Return the current stack trace." eq? "Return `T` if `a` and `b` are the same object, `NIL` otherwise.\n\nExamples:\n\n (eq? 0.0 0)\n ; ↳ NIL\n\n (eq? 0 0)\n ; ↳ T\n\n (def a \"1\")\n (def b \"1\")\n (eq? a b)\n ; ↳ NIL\n\n (def a '(1))\n (def b '(1))\n (eq? a b)\n ; ↳ NIL" io->str "Return the data of the in-memory `io` buffer as a string." bound? "Return `T` if `sym` has a value associated with it, `NIL` otherwise.\n\nExamples:\n\n (bound? 'bound?)\n ; ↳ T\n\n (bound? 'doesnotcompute)\n ; ↳ NIL" list->vec "Return the list converted to a vector.\n\nExamples:\n\n (list->vec '(1 2 a))\n ; ↳ #(1 2 a)" odd? "Return `T` if `n` is an odd integer, `NIL` otherwise." def "Assign the function (first form) or the result of the expression\n(second form) to the identifier.\n\nDocumentation for the definition may also be supplied after `form` in\nthe same manner as with `defdoc`.\n\nFunction definitions themselves may contain other definitions internal\nto the function.\n\nExamples:\n\n ; a function with documentation (first form)\n (def (f x)\n \"Return the square of doubled `x`.\n\n Examples:\n\n (f 3)\n ; ↳ 36\"\n :doc-group cool-funcs ; documentation group for (help groups)\n :doc-see g ; reference another function in the documentation\n (def (g y) ; an internal function\n (+ y y))\n (* (g x) (g x)))\n (f 2)\n ; ↳ 16\n\n ; a variable (second form)\n (def x (length \"hello\"))\n x\n ; ↳ 5" list? "Return `T` if the value is either `NIL` or a cons cell, `NIL`\notherwise." *os-version* "The \"version\" of the operating system this StreetLISP VM executable\nwas built for.\n\nThe availability of the constant and its value depends on the\noperating system and is only provided for the user to see. No logic\nshould depend on it.\n\nExamples:\n\n *os-version*\n ; ↳ \"6.14.5-0-edge\" ; Alpine Linux kernel version" str-rep "Return the concatenation of the term formatted as a string, repeated\n`k` times.\n\nExamples:\n\n (str-rep \"oi\" 3)\n ; ↳ \"oioioi\"\n\n (str-rep #\\ы 5)\n ; ↳ \"ыыыыы\"\n\n (str-rep 'a 3)\n ; ↳ \"aaa\"\n\n (str-rep 1 5)\n ; ↳ \"11111\"" time "Display the elapsed time of evaluating `expr` to `*io-out*`, return\nthe result of the evaluated expression.\n\nExamples:\n\n (time (begin (sleep 0.1) 12345))\n ; ‼ Elapsed time: 0.10013356 seconds\n ; ↳ 12345" size-of "Return the size of the value in bytes, if applicable.\n\nWorks only with C integer types, arrays, strings and in-memory\nbuffers.\n\nExamples:\n\n (size-of \"hello\")\n ; ↳ 5\n\n (size-of (arr 'u32 1 2 3))\n ; ↳ 12\n\n (def b (buffer))\n (io-write b \"hello\")\n (size-of b)\n ; ↳ 5" sym "Return a symbol with the name being the concatenation of terms\nformatted as strings.\n\nThis is equivalent to `(sym (str …))`.\n\nExamples:\n\n (sym \"a\" 'b 1)\n ; ↳ ab1" tanh "Return the hyperbolic tangent of `x`." for "Call the function `f` with a single integer argument, starting from\n`min` and ending with `max`.\n\nExamples:\n\n (for 0 2 (λ (i) (print (- 2 i))))\n ; ‼ 210" begin "Evaluate the expressions in order and return the result of the last\nexpression.\n\nExamples:\n\n (if 1\n (begin (print 1)\n (newline)\n 'ignored\n 'done)\n (begin (print 0)\n (newline)\n 'else))\n ; ‼ 1\n ; ↳ done" const? "Return `T` if the term refers to a constant, `NIL` otherwise.\n\nConstants cannot be modified with `set!`. Trying to do so will result\nin an e
\ No newline at end of file
group array) "Arrays and vectors." mod "Return the remainder of the Euclidean division `a/n`.\n\nExamples:\n\n (mod 10 3)\n ; ↳ 1\n\n (mod -10 3)\n ; ↳ 2\n\n (mod -10 -3)\n ; ↳ 2\n\n (mod 10 -3)\n ; ↳ 1" if "Return the result of `then` if `cond` evaluated as \"true\", `else`\notherwise.\n\nThe `else` is not optional unlike in many other LISP implementations.\nPrimary purpose is to spot errors involving wrong parenthesis\nplacement. Another reason is to force a certain coding style.\n\nExamples:\n\n (def x '(1))\n (if x 'yes 0)\n ; ↳ yes\n (if (str? x) 1 'no)\n ; ↳ no" p32 "Construct a 32-bit abstract pointer value." io-read-lines "Return a list of lines read from the IO object until it ran out of\ndata.\n\nThe file is split into lines by `#\\linefeed`. Each string will have\nthe character, except the last line if EOF has been reached\nbeforehand.\n\nExamples:\n\n ; read current process' segments on Plan 9\n (def seg (file (str \"/proc/\" (getpid) \"/segment\")))\n (io-read-lines seg)\n ; ↳ (\"Stack 1feff0000 1ffff0000 1\\n\"\n \"Text R 10000 70000 1\\n\"\n \"Data 70000 d0000 1\\n\"\n \"Bss d0000 1a0000 1\\n\"\n \"Bss 1fcff0000 1feff0000 1\\n\"\n \"Bss 1faff0000 1fcff0000 1\\n\")" sym-set-doc "Set the documentation for the symbol." macrocall? "Return the macro application function if `e` refers to a macro call,\n`NIL` otherwise.\n\nExamples:\n\n (macrocall? '(car NIL))\n ; ↳ NIL\n\n (macrocall? '(let ((x 1)) 2))\n ; ↳ #fn(...)" trycatch "Return the result of evaluation of the expression `try` or, if an\nexception has been thrown, the one-argument function `catch`.\n\nExamples:\n\n (trycatch (+ 1 2) (λ (e) e))\n ; ↳ 3\n (trycatch (+ 1 NIL) (λ (e) e))\n ; ↳ (type-error num NIL)" (doc
@@ -76,7 +76,7 @@
(arr u32)" top-level-value "Return the value bound to the symbol in the top level (global)\nenvironment.\n\nExamples:\n\n (def abc 1)\n (let {[abc 2]}\n (cons abc (top-level-value 'abc)))\n ; ↳ (2 . 1)\n abc\n ; ↳ 1" defstruct "Declare a new structure type with the specified name and slots.\n\nThe default underlying type is a \"named\" vector (`:type vec`), where\nthe first element is the name of the structure's type, the rest are\nthe keyworded slot values. A list with slot values alone can be used\ninstead by adding `:type list` option. The list will not contain the\nname of the struct by default, which can be enabled with `:named T`\noption.\n\nAs an example, the following declaration generates the default\nconstructor for a structure of three slots, with one of them (`c`)\nhaving a non-`NIL` default value and marked as read-only:\n\n (defstruct blah \"Return stuff.\" :doc-group stuff a b (c 1 :read-only T))\n ; (make-blah (:a NIL) (:b NIL) (:c 1))\n ; (blah-a s)\n ; (blah-b s)\n ; (blah-c s)\n\nSlot's options, if any, should be specified after its default value.\nSupported options are:\n\n ; mark the slot as read-only\n ; its value can be read, but trying to modify it will throw an error\n … :read-only T\n\nThe constructor can be changed in several ways:\n\n ; disable the constructor altogether\n (defstruct blah :constructor NIL a b c)\n ; only change its name\n (defstruct blah :constructor blargh a b c)\n ; rename AND avoid using keywords\n (defstruct blah :constructor (blah a b c) a b c)\n\nThe option `:conc-name` specifies the slot accessor prefix, which\ndefaults to `structname-`. Prefix can be disabled entirely with\n`:conc-name NIL`.\n\nDefault predicate can be disabled or its name, which defaults to\n`structname?`, changed:\n\n ; use \"blargh?\" instead of \"blah?\"\n (defstruct blah :predicate blargh? a b c)\n ; without predicate\n (defstruct blah :predicate NIL a b c)" caadar "Shorthand for (car (car (cdr (car lst))))." buffer "Return an in-memory buffer for I/O, of `io` type.\n\nA buffer can be used for both reading and writing at the same\ntime." assoc-list "Construct an association list from the arguments.\n\nEvery two arguments are expected to be a key and a value associated\nwith that key.\n\nExamples:\n\n (assoc-list 'a 0 'b 1)\n ; ↳ ((a . 0) (b . 1))" builtin? "Return `T` if `v` is a built-in function implemented in C, `NIL`\notherwise.\n\nExamples:\n\n (builtin? map)\n ; ↳ T\n\n (builtin? macroexpand)\n ; ↳ NIL" str-map "Return the concatenation of the values produced by `fn` when applying\nto each rune of the string `s`.\n\nFunction `fn` may return a value of any type suitable for `io-write` -\na rune, string, array of C primitives. If `fn` returns `NIL`, the\nrune is ignored.\n\nExamples:\n\n (str-map rune-upcase\n \"hello, world!\")\n ; ↳ \"HELLO, WORLD!\"\n\n (str-map (λ (r) (str r r))\n \"hello\")\n ; ↳ \"hheelllloo\"\n\n (str-map (λ (r) (and (not (rune-whitespace? r)) r))\n \"! this is great !\")\n ; ↳ \"!thisisgreat!\"" macroexpand-1 "Return a macro-expanded expression.\n\nIf the expression is not a macro call, it is returned unchanged.\nOnly a single level of expansion is performed.\n\nExamples:\n\n (let ((a 3) (b 4) (c 5))\n (macroexpand-1 `(let* {[x ,a] [y ,b]} (+ x y ,c))))\n ; ↳ ((λ (x) ; note how the inner let* expression isn't expanded\n (let* ((y 4)) (+ x y 5)))\n 3)" str "Return concatenation of terms formatted as strings.\n\nThis is equivalent to `(princ terms…)`, except the string is\n_returned_, rather than printed.\n\nExamples:\n\n (str \"a\" 'b 1 #(0))\n ; ↳ \"ab1#(0)\"" negative? "Return `T` if `n` is a negative number. Shorthand for `(< n 0)`." void "Return the constant `#<void>` while ignoring any arguments.\n\n`#<void>` is mainly used when a function has side effects but does not\nproduce any meaningful value to return, so even though `T` or `NIL` could\nb
\ No newline at end of file
group prop) "Dealing with properties of symbols." (doc group vm) "VM-related functions." equal? "Return `T` if both `a` and `b` are of the same value. For non-leaf\ntypes (cons cell and vector), the equality test is performed\nthroughout the whole structure of the values.\n\nExamples:\n\n (equal? 0.0 0)\n ; ↳ NIL\n\n (equal? 0 0)\n ; ↳ T\n\n (def a \"1\")\n (def b \"1\")\n (equal? a b)\n ; ↳ T\n\n (def a '(1))\n (def b '(1))\n (equal? a b)\n ; ↳ T" cddar "Shorthand for (cdr (cdr (car lst)))." *interactive* "Variable indicating whether VM is running in \"interactive\" mode (`T`,\nREPL is active) or not (`NIL`, REPL is not active).\n\nInteractive mode can be forced by adding `-i` as the first command\nline argument." unquote "Evaluate the expression, which is a part of a quasiquoted expression\nitself.\n\nShorthand for `(unquote expr)`.\n\nExamples:\n\n `(0 1 ,(+ 2 3)) ; same as (quasiquote (0 1 (unquote (+ 2 3))))\n ; ↳ (0 1 5)" or "Return the first evaluated argument that is not `NIL` and stop\nevaluating the rest of the arguments. Return `NIL` otherwise.\n\nExamples:\n\n (or)\n ; ↳ NIL\n\n (or 1 2 (print 'first) (print 'second) 3)\n ; ↳ 1\n\n (or NIL NIL (print 'first) (print 'second) 3)\n ; ‼ first" = "Numerical equality test. Return `T` if all numbers are equal,\n`NIL` otherwise." fn? "Return `T` if `v` is a function, `NIL` otherwise.\n\nExamples:\n\n (fn? (void))\n ; ↳ NIL\n\n (fn? map)\n ; ↳ T\n\n (fn? macroexpand)\n ; ↳ T" (doc
group type) "Dealing with types." caaadr "Shorthand for (car (car (car (cdr lst))))." make-system-image "Build and store a \"system image\" of the runtime environment to a file." subseq "Return a bounded part of a sequence.\n\nThe returned value is always a copy of the subsequence of the\noriginal. It is an error if either `start` or `end` (if specified)\nare out of bounds.\n\nExamples:\n\n (subseq \"hello\" 1 2)\n ; ↳ \"e\"\n\n (subseq '(1 2 3) 0 2)\n ; ↳ (1 2)\n\n (subseq #(a b c) 2)\n ; ↳ #(c)" set! "Evaluate the expression, assign the result to the identifier and\nreturn the value.\n\nThe identifier must already be bound in the same environment,\notherwise this results in a compilation error.\n\nMultiple identifiers and expressions may be specified in pairs. The\nreturned value will be the result of the last expression.\n\nExamples:\n\n (def a NIL)\n (def b NIL)\n (def c NIL)\n (set! a 1 b 2 c (+ a b))\n ; ↳ 3\n a\n ; ↳ 1\n b\n ; ↳ 2\n c\n ; ↳ 3" vm-stats "Print various VM-related information, such as the number of GC\ncalls so far, heap and stack size, etc." ptr "Construct an abstract pointer value. The bit width is either 32-bit\nor 64-bit, depending on the platform the code is executing on.\n\nNote: certain arithmetic operations on pointers, such as division and\nmultiplication, will throw an error. This is done on purpose since\ndoing that on pointers rarely makes sense." caddar "Shorthand for (car (cdr (cdr (car lst))))." print-stack-trace "Print the stacktrace." *stdin* "Standard input IO stream." cosh "Return the hyperbolic cosine of `x`." < "Return `T` if the arguments are in strictly increasing order (next\none is greater than the previous one). With a single argument\nthe result is always `T`." (doc
-ctor), the equality test is performed\nthroughout the whole structure of the values.\n\nExamples:\n\n (equal? 0.0 0)\n ; ↳ NIL\n\n (equal? 0 0)\n ; ↳ T\n\n (def a \"1\")\n (def b \"1\")\n (equal? a b)\n ; ↳ T\n\n (def a '(1))\n (def b '(1))\n (equal? a b)\n ; ↳ T" cddar "Shorthand for (cdr (cdr (car lst)))." *interactive* "Variable indicating whether VM is running in \"interactive\" mode (`T`,\nREPL is active) or not (`NIL`, REPL is not active).\n\nInteractive mode can be forced by adding `-i` as the first command\nline argument." unquote "Evaluate the expression, which is a part of a quasiquoted expression\nitself.\n\nShorthand for `(unquote expr)`.\n\nExamples:\n\n `(0 1 ,(+ 2 3)) ; same as (quasiquote (0 1 (unquote (+ 2 3))))\n ; ↳ (0 1 5)" or "Return the first evaluated argument that is not `NIL` and stop\nevaluating the rest of the arguments. Return `NIL` otherwise.\n\nExamples:\n\n (or)\n ; ↳ NIL\n\n (or 1 2 (print 'first) (print 'second) 3)\n ; ↳ 1\n\n (or NIL NIL (print 'first) (print 'second) 3)\n ; ‼ first" = "Numerical equality test. Return `T` if all numbers are equal,\n`NIL` otherwise." fn? "Return `T` if `v` is a function, `NIL` otherwise.\n\nExamples:\n\n (fn? (void))\n ; ↳ NIL\n\n (fn? map)\n ; ↳ T\n\n (fn? macroexpand)\n ; ↳ T" (doc
+ctor), the equality test is performed\nthroughout the whole structure of the values.\n\nExamples:\n\n (equal? 0.0 0)\n ; ↳ NIL\n\n (equal? 0 0)\n ; ↳ T\n\n (def a \"1\")\n (def b \"1\")\n (equal? a b)\n ; ↳ T\n\n (def a '(1))\n (def b '(1))\n (equal? a b)\n ; ↳ T" cddar "Shorthand for (cdr (cdr (car lst)))." *interactive* "Variable indicating whether VM is running in \"interactive\" mode (`T`,\nREPL is active) or not (`NIL`, REPL is not active).\n\nInteractive mode can be forced by adding `-i` as the first command\nline argument." unquote "Evaluate the expression, which is a part of a quasiquoted expression\nitself.\n\nShorthand for `(unquote expr)`.\n\nExamples:\n\n `(0 1 ,(+ 2 3)) ; same as (quasiquote (0 1 (unquote (+ 2 3))))\n ; ↳ (0 1 5)" or "Return the first evaluated argument that is not `NIL` and stop\nevaluating the rest of the arguments. Return `NIL` otherwise.\n\nExamples:\n\n (or)\n ; ↳ NIL\n\n (or 1 2 (print 'first) (print 'second) 3)\n ; ↳ 1\n\n (or NIL NIL (print 'first) (print 'second) 3)\n ; ‼ first" = "Numerical equality test. Return `T` if all numbers are equal,\n`NIL` otherwise." fn? "Return `T` if `v` is a function, `NIL` otherwise.\n\nExamples:\n\n (fn? (void))\n ; ↳ NIL\n\n (fn? map)\n ; ↳ T\n\n (fn? macroexpand)\n ; ↳ T" (doc
macroexpand)\n ; ↳ T" (doc
group type) "Dealing with types." caaadr "Shorthand for (car (car (car (cdr lst))))." make-system-image "Build and store a \"system image\" of the runtime environment to a file." subseq "Return a bounded part of a sequence.\n\nThe returned value is always a copy of the subsequence of the\noriginal. It is an error if either `start` or `end` (if specified)\nare out of bounds.\n\nExamples:\n\n (subseq \"hello\" 1 2)\n ; ↳ \"e\"\n\n (subseq '(1 2 3) 0 2)\n ; ↳ (1 2)\n\n (subseq #(a b c) 2)\n ; ↳ #(c)" set! "Evaluate the expression, assign the result to the identifier and\nreturn the value.\n\nThe identifier must already be bound in the same environment,\notherwise this results in a compilation error.\n\nMultiple identifiers and expressions may be specified in pairs. The\nreturned value will be the result of the last expression.\n\nExamples:\n\n (def a NIL)\n (def b NIL)\n (def c NIL)\n (set! a 1 b 2 c (+ a b))\n ; ↳ 3\n a\n ; ↳ 1\n b\n ; ↳ 2\n c\n ; ↳ 3" vm-stats "Print various VM-related information, such as the number of GC\ncalls so far, heap and stack size, etc." ptr "Construct an abstract pointer value. The bit width is either 32-bit\nor 64-bit, depending on the platform the code is executing on.\n\nNote: certain arithmetic operations on pointers, such as division and\nmultiplication, will throw an error. This is done on purpose since\ndoing that on pointers rarely makes sense." caddar "Shorthand for (car (cdr (cdr (car lst))))." print-stack-trace "Print the stacktrace." *stdin* "Standard input IO stream." cosh "Return the hyperbolic cosine of `x`." < "Return `T` if the arguments are in strictly increasing order (next\none is greater than the previous one). With a single argument\nthe result is always `T`." (doc
group time) "Measuring, manipulating and displaying time." copy-tree "Return a recursive copy of the list.\n\nUnlike `copy-list`, this function copies subelements of the list\nrecursively.\n\nExamples:\n\n (def a '(1 (2 3)))\n (def b (copy-tree a))\n (equal? a b)\n ; ↳ T\n (eq? a b)\n ; ↳ NIL\n (equal? (cadr a) (cadr b))\n ; ↳ T\n (eq? (cadr a) (cadr b))\n ; ↳ NIL" f32 "Construct a 32-bit floating point number." sin "Return the sine of `r`, where `r` is given in radians." delete-duplicates "Return a copy of the list with duplicated elements removed.\n\nElements are tested for duplicates using `equal?`. The order of the\nelements is preserved in the resulting list.\n\nExamples:\n\n (delete-duplicates '(a 0 b c1 a b 3 c 5))\n ; ↳ (a 0 b c1 3 c 5)" > "Return `T` if the arguments are in strictly decreasing order (previous\none is greater than the next one)." str-rune "Return the nth rune of the string.\n\nThrows an exception if the index `n` is out of bounds.\n\nExamples:\n\n (str-rune \"йцукен\" 3)\n ; ↳ #\\к" with-output-to "Evaluate expressions in `body` with `*io-out*` set to `io` during the\nevaluation.\n\nExamples:\n\n ; write a string \"hello, world!\" to a file\n ; end with a newline\n (with-output-to (file \"/tmp/1.txt\" :create :truncate :write)\n (print \"hello, world!\")\n (newline))" abs "Return absolute value of the argument." *linefeed* "OS-specific _line_ _feed_ value.\n\nIt is preferred over hardcoded `\"\\n\"`, for portability." str? "Return `T` if the argument is a string, `NIL` otherwise." cons? "Return `T` if `v` is a cons cell, `NIL` otherwise.\n\nExamples:\n\n (cons? 0)\n ; ↳ NIL\n\n (cons? NIL)\n ; ↳ NIL\n\n (cons? '(1))\n ; ↳ T" str-split "Return a list of substrings of `str` by splitting at any character in\nthe string `sep`. The splitting characters are removed.\n\nBy default the string is split on space, line feed (newline),\nhorizontal and vertical tab, and form feed.\n\nTrim removes empty strings from the list.\n\nExamples:\n\n (str-split \"hello world\")\n ; ↳ (\"hello\" \"world\")\n\n (str-split \"multiple spaces \")\n ; ↳ (\"multiple\" \"\" \"\" \"spaces\" \"\")\n\n (str-split \"multiple spaces \" :trim T)\n ; ↳ (\"multiple\" \"spaces\")\n\n (str-split \"too many vowels\" \"aeiou\")\n ; ↳ (\"t\" \"\" \" m\" \"ny v\" \"w\" \"ls\")" aset! "Modify the sequence element specified by the subscripts and return the\nnew value. The sequence can be an array, vector, a list.\nMulti-dimensional sequences of variating types are also supported.\n\nExamples:\n\n (def a '((1 #(2 (3)) 4)))\n (aset! a 1 'x)\n ; ‼ index 1 out of bounds\n (aset! a 0 0 'x)\n ; ↳ x\n a\n ; ↳ ((x #(2 (3)) 4))\n (aset! a 0 1 9)\n ; ↳ 9\n a\n ; ↳ ((x #(9 (3)) 4))" - "Return the result of subtraction. With only one argument a\nnegation is performed.\n\nExamples:\n\n (- 1.5)\n ; ↳ -1.5\n\n (- 3 2)\n ; ↳ 1" makunbound "Make the symbol unbound.\n\nExamples:\n\n (def x 1)\n (bound? 'x)\n ; ↳ T\n x\n ; ↳ 1\n (makunbound 'x)\n (bound? 'x)\n ; ↳ NIL\n x\n ; ‼ eval: variable x has no value" rand "Return a random non-negative fixnum on its maximum range." quasiquote "Same as `'expr` but allows evaluating (\"unquoting\") parts of\nthe expression.\n\nShorthand for `(quasiquote expr)`.\n\nExamples:\n\n `(0 1 (+ 2 3)) ; same as (quasiquote (0 1 (+ 2 3)))\n ; ↳ (0 1 (+ 2 3))" copy-list "Return a copy of the list.\n\nThe number of elements to be copied can be limited with the optional\nargument `n`.\n\nExamples:\n\n (def a '(1 2 3 4))\n (def b (copy-list a))\n b\n ; ↳ (1 2 3 4)\n (eq? a b)\n ; ↳ NIL\n (equal? a b)\n ; ↳ T\n (copy-list a 3)\n ; ↳ (1 2 3)\n (copy-list a 10)\n ; ↳ (1 2 3 4)" logand "Return the result of bitwise AND operation on integers.\n\nExamples:\n\n (logand)\n ; ↳ 0\n\n (logand 2)\n ; ↳ 2\n\n (logand 2 3
\ No newline at end of file
@@ -91,8 +91,9 @@
oad\nfinishes.\n\nExamples:\n\n (load \"stuff.sl\")" getpid "Return the process ID of the StreetLISP VM within the operating system\nit's running on." keyword? "Return `T` if the argument is a keyword, `NIL` otherwise." aref "Return the sequence element specified by the subscripts. The sequence\ncan be an array, vector, a list. Multi-dimensional sequences\nof variating types are also supported.\n\nExamples:\n\n (def a '((1 #(2 (3)) 4)))\n (aref a 0)\n ; ↳ (1 (2 (3)) 4)\n (aref a 1)\n ; ‼ index 1 out of bounds\n (aref a 0 0)\n ; ↳ 1\n (aref a 0 1 0)\n ; ↳ 2\n (aref a 0 2)\n ; ↳ 4" sym? "Return `T` if `v` is a symbol, `NIL` otherwise." defmacro "Define a new macro.\n\nExamples:\n\n (defmacro (inc! v)\n \"Increments and returns the value.\"\n :doc-group my-cool-macros\n :doc-see my-other-cool-macro\n (if (num? v)\n (1+ v)\n `(set! ,v (1+ ,v))))\n (inc! 1)\n ; ↳ 2\n (set! x 1)\n (inc! x)\n ; ↳ 2\n x\n ; ↳ 2" u64 "Construct a 64-bit unsigned number." Instructions "VM instructions mapped to their encoded byte representation." assv "Return a pair of a matching key and the associated value, or `NIL` if\nnone matched. Keys are compared using `eqv?`." bignum "Construct a bignum. As opposed to a fixnum, its value is not limited." copy-vec "Return a new copy of the vector with the elements.\n\nNo copies of the keys nor values are created - original ones are\nreused.\n\nExamples:\n\n (def v #vec(a (1 2 3)))\n (def q (copy-vec v))\n (eq? v q)\n ; ↳ NIL\n (equal? v q)\n ; ↳ T" *os-name* "The name of the operating system this StreetLISP VM executable was\nbuilt for.\n\nIt's set to a lowercase string and its value is considered \"best\neffort\" - it might not always be accurate.\n\nPossible values: `\"unknown\"`, `\"plan9\"`, `\"linux\"`, `\"openbsd\"`,\n`\"netbsd\"`, `\"dragonflybsd\"`, `\"freebsd\"`, `\"haiku\"`, `\"macosx\"`,\n`\"macos\"`, `\"dos\"`." eqv? "Return `T` if both `a` and `b` are of the same value and primitive\n(leaf) type, `NIL` otherwise. Neither cons cell nor vector are not\nconsidered primitive types as they may define deep structures.\n\nExamples:\n\n (eqv? 0.0 0)\n ; ↳ NIL\n\n (eqv? 0 0)\n ; ↳ T\n\n (def a \"1\")\n (def b \"1\")\n (eqv? a b)\n ; ↳ T\n\n (def a '(1))\n (def b '(1))\n (eqv? a b)\n ; ↳ NIL" list "Return a list constructed of the arguments.\n\nExamples:\n\n (list) ; empty list\n ; ↳ NIL\n\n (list 1 2.5 \"a\" 'b)\n ; ↳ (1 2.5 \"a\" b)" __init_globals "Initialize globals that need to be set at load time." rand-u32 "Return a random integer on interval [0, 2³²-1]." revappend "Return list with its elements in reverse order, with `tail` appended\nto its end.\n\nThe original list is copied to construct the reversed version.\n\nExamples:\n\n (def a '(4 5 6))\n (revappend a '(3 2 1))\n ; ↳ (6 5 4 3 2 1)\n a\n ; ↳ (4 5 6)" quote "Leave the expression unevaluated.\n\nShorthand for `(quote expr)`.\n\nExamples:\n\n '(0 1 (+ 2 3)) ; same as (quote (0 1 (+ 2 3)))\n ; ↳ (0 1 (+ 2 3))" nreconc "Return list with its elements in reverse order, with `tail` appended\nto its end.\n\nThe original list may be modified by this function.\n\nExamples:\n\n (def a '(4 5 6))\n (nreconc a '(3 2 1))\n ; ↳ (6 5 4 3 2 1)" defc*r "Define a shorthand for list access using `car` and `cdr`.\n\nExamples:\n\n (defc*r caaaaaaaaddr) ; define the function" (doc
group misc) "Miscellaneous." read-all-of "Call `fn` on an IO object until it runs out of data. Return the list\ncontaining the values returned by `fn` on each call." cddddr "Shorthand for (cdr (cdr (cdr (cdr lst))))." prog1 "Evaluate the expressions in order, return the result of the first one.\n\nExamples:\n\n (prog1 (+ 1 2 3)\n (print \"hi\")\n (newline))\n ; ↳ 6" logior "Return the result of bitwise OR (inclusive OR) operation on integers.\n\nExamples:\n\n (logior)\n ; ↳ 0\n\n (logior 2)\n ; ↳ 2\n\n (logior 2 3)\n ; ↳ 3\n\n (logior 2 3 4)\n ; ↳ 7" cadr "Shorthand for `(car (cdr lst))`, that is, _first element of the\nsecond element_.\n\nExamples:\n\n (cadr '(1 2 3))\n ; ↳ 2\n\n (cadr '(1))\n ; ↳ NIL\n\n (cadr NIL)\n ; ↳ NIL" cdadr "Shorthand for (cdr (car (cdr lst)))." (doc
group doc) "Writing and reading documentation." nan? "Return `T` if `v` is a floating point representation of NaN, either\nnegative or positive, `NIL` otherwise." caar "Shorthand for (car (car lst))." div0 "Return the quotient of the truncated division `a/n`.\n\nExamples:\n\n (div0 10 3)\n ; ↳ 3\n\n (div0 -10 3)\n ; ↳ -3\n\n (div0 -10 -3)\n ; ↳ 3\n\n (div0 10 -3)\n ; ↳ -3" set-syntax! "Associate a macro name with its application function." mod0 "Return the remainder of the truncated division `a/n`.\n\nExamples:\n\n (mod0 10 3)\n ; ↳ 1\n\n (mod0 -10 3)\n ; ↳ -1\n\n (mod0 -10 -3)\n ; ↳ -1\n\n (mod0 10 -3)\n ; ↳ 1" last-pair "Return the last cell (pair) of the list.\n\nExamples:\n\n (last-pair '(1 2 3))\n ; ↳ (3)\n\n (last-pair '(1 2 . 3))\n ; ↳ (2 . 3)" path-cwd "Return the full path to the current directory of the process, or\nchange it to the path specified with `to` argument." (doc
-re also supported.\n\nExamples:\n\n (def a '((1 #(2 (3)) 4)))\n (aref a 0)\n ; ↳ (1 (2 (3)) 4)\n (aref a 1)\n ; ‼ index 1 out of bounds\n (aref a 0 0)\n ; ↳ 1\n (aref a 0 1 0)\n ; ↳ 2\n (aref a 0 2)\n ; ↳ 4" sym? "Return `T` if `v` is a symbol, `NIL` otherwise." defmacro "Define a new macro.\n\nExamples:\n\n (defmacro (inc! v)\n \"Increments and returns the value.\"\n :doc-group my-cool-macros\n :doc-see my-other-cool-macro\n (if (num? v)\n (1+ v)\n `(set! ,v (1+ ,v))))\n (inc! 1)\n ; ↳ 2\n (set! x 1)\n (inc! x)\n ; ↳ 2\n x\n ; ↳ 2" u64 "Construct a 64-bit unsigned number." Instructions "VM instructions mapped to their encoded byte representation." assv "Return a pair of a matching key and the associated value, or `NIL` if\nnone matched. Keys are compared using `eqv?`." bignum "Construct a bignum. As opposed to a fixnum, its value is not limited." copy-vec "Return a new copy of the vector with the elements.\n\nNo copies of the keys nor values are created - original ones are\nreused.\n\nExamples:\n\n (def v #vec(a (1 2 3)))\n (def q (copy-vec v))\n (eq? v q)\n ; ↳ NIL\n (equal? v q)\n ; ↳ T" *os-name* "The name of the operating system this StreetLISP VM executable was\nbuilt for.\n\nIt's set to a lowercase string and its value is considered \"best\neffort\" - it might not always be accurate.\n\nPossible values: `\"unknown\"`, `\"plan9\"`, `\"linux\"`, `\"openbsd\"`,\n`\"netbsd\"`, `\"dragonflybsd\"`, `\"freebsd\"`, `\"haiku\"`, `\"macosx\"`,\n`\"macos\"`, `\"dos\"`." eqv? "Return `T` if both `a` and `b` are of the same value and primitive\n(leaf) type, `NIL` otherwise. Neither cons cell nor vector are not\nconsidered primitive types as they may define deep structures.\n\nExamples:\n\n (eqv? 0.0 0)\n ; ↳ NIL\n\n (eqv? 0 0)\n ; ↳ T\n\n (def a \"1\")\n (def b \"1\")\n (eqv? a b)\n ; ↳ T\n\n (def a '(1))\n (def b '(1))\n (eqv? a b)\n ; ↳ NIL" list "Return a list constructed of the arguments.\n\nExamples:\n\n (list) ; empty list\n ; ↳ NIL\n\n (list 1 2.5 \"a\" 'b)\n ; ↳ (1 2.5 \"a\" b)" __init_globals "Initialize globals that need to be set at load time." rand-u32 "Return a random integer on interval [0, 2³²-1]." revappend "Return list with its elements in reverse order, with `tail` appended\nto its end.\n\nThe original list is copied to construct the reversed version.\n\nExamples:\n\n (def a '(4 5 6))\n (revappend a '(3 2 1))\n ; ↳ (6 5 4 3 2 1)\n a\n ; ↳ (4 5 6)" quote "Leave the expression unevaluated.\n\nShorthand for `(quote expr)`.\n\nExamples:\n\n '(0 1 (+ 2 3)) ; same as (quote (0 1 (+ 2 3)))\n ; ↳ (0 1 (+ 2 3))" nreconc "Return list with its elements in reverse order, with `tail` appended\nto its end.\n\nThe original list may be modified by this function.\n\nExamples:\n\n (def a '(4 5 6))\n (nreconc a '(3 2 1))\n ; ↳ (6 5 4 3 2 1)" defc*r "Define a shorthand for list access using `car` and `cdr`.\n\nExamples:\n\n (defc*r caaaaaaaaddr) ; define the function" (doc
-group misc) "Miscellaneous." read-all-of "Call `fn` on an IO object until it runs out of data. Return the list\ncontaining the values returned by `fn` on each call." cddddr "Shorthand for (cdr (cdr (cdr (cdr lst))))." prog1 "Evaluate the expressions in order, return the result of the first one.\n\nExamples:\n\n (prog1 (+ 1 2 3)\n (print \"hi\")\n (newline))\n ; ↳ 6" logior "Return the result of bitwise OR (inclusive OR) operation on integers.\n\nExamples:\n\n (logior)\n ; ↳ 0\n\n (logior 2)\n ; ↳ 2\n\n (logior 2 3)\n ; ↳ 3\n\n (logior 2 3 4)\n ; ↳ 7" cadr "Shorthand for `(car (cdr lst))`, that is, _first element of the\nsecond element_.\n\nExamples:\n\n (cadr '(1 2 3))\n ; ↳ 2\n\n (cadr '(1))\n ; ↳ NIL\n\n (cadr NIL)\n ; ↳ NIL" cdadr "Shorthand for (cdr (car (cdr lst)))." (doc
+re also supported.\n\nExamples:\n\n (def a '((1 #(2 (3)) 4)))\n (aref a 0)\n ; ↳ (1 (2 (3)) 4)\n (aref a 1)\n ; ‼ index 1 out of bounds\n (aref a 0 0)\n ; ↳ 1\n (aref a 0 1 0)\n ; ↳ 2\n (aref a 0 2)\n ; ↳ 4" sym? "Return `T` if `v` is a symbol, `NIL` otherwise." defmacro "Define a new macro.\n\nExamples:\n\n (defmacro (inc! v)\n \"Increments and returns the value.\"\n :doc-group my-cool-macros\n :doc-see my-other-cool-macro\n (if (num? v)\n (1+ v)\n `(set! ,v (1+ ,v))))\n (inc! 1)\n ; ↳ 2\n (set! x 1)\n (inc! x)\n ; ↳ 2\n x\n ; ↳ 2" u64 "Construct a 64-bit unsigned number." Instructions "VM instructions mapped to their encoded byte representation." assv "Return a pair of a matching key and the associated value, or `NIL` if\nnone matched. Keys are compared using `eqv?`." bignum "Construct a bignum. As opposed to a fixnum, its value is not limited." copy-vec "Return a new copy of the vector with the elements.\n\nNo copies of the keys nor values are created - original ones are\nreused.\n\nExamples:\n\n (def v #vec(a (1 2 3)))\n (def q (copy-vec v))\n (eq? v q)\n ; ↳ NIL\n (equal? v q)\n ; ↳ T" *os-name* "The name of the operating system this StreetLISP VM executable was\nbuilt for.\n\nIt's set to a lowercase string and its value is considered \"best\neffort\" - it might not always be accurate.\n\nPossible values: `\"unknown\"`, `\"plan9\"`, `\"linux\"`, `\"openbsd\"`,\n`\"netbsd\"`, `\"dragonflybsd\"`, `\"freebsd\"`, `\"haiku\"`, `\"macosx\"`,\n`\"macos\"`, `\"dos\"`." eqv? "Return `T` if both `a` and `b` are of the same value and primitive\n(leaf) type, `NIL` otherwise. Neither cons cell nor vector are not\nconsidered primitive types as they may define deep structures.\n\nExamples:\n\n (eqv? 0.0 0)\n ; ↳ NIL\n\n (eqv? 0 0)\n ; ↳ T\n\n (def a \"1\")\n (def b \"1\")\n (eqv? a b)\n ; ↳ T\n\n (def a '(1))\n (def b '(1))\n (eqv? a b)\n ; ↳ NIL" list "Return a list constructed of the arguments.\n\nExamples:\n\n (list) ; empty list\n ; ↳ NIL\n\n (list 1 2.5 \"a\" 'b)\n ; ↳ (1 2.5 \"a\" b)" __init_globals "Initialize globals that need to be set at load time." rand-u32 "Return a random integer on interval [0, 2³²-1]." revappend "Return list with its elements in reverse order, with `tail` appended\nto its end.\n\nThe original list is copied to construct the reversed version.\n\nExamples:\n\n (def a '(4 5 6))\n (revappend a '(3 2 1))\n ; ↳ (6 5 4 3 2 1)\n a\n ; ↳ (4 5 6)" quote "Leave the expression unevaluated.\n\nShorthand for `(quote expr)`.\n\nExamples:\n\n '(0 1 (+ 2 3)) ; same as (quote (0 1 (+ 2 3)))\n ; ↳ (0 1 (+ 2 3))" nreconc "Return list with its elements in reverse order, with `tail` appended\nto its end.\n\nThe original list may be modified by this function.\n\nExamples:\n\n (def a '(4 5 6))\n (nreconc a '(3 2 1))\n ; ↳ (6 5 4 3 2 1)" defc*r "Define a shorthand for list access using `car` and `cdr`.\n\nExamples:\n\n (defc*r caaaaaaaaddr) ; define the function" (doc
+group misc) "Miscellaneous." read-all-of "Call `fn` on an IO object until it runs out of data. Return the list\ncontaining the values returned by `fn` on each call." cddddr "Shorthand for (cdr (cdr (cdr (cdr lst))))." prog1 "Evaluate the expressions in order, return the result of the first one.\n\nExamples:\n\n (prog1 (+ 1 2 3)\n (print \"hi\")\n (newline))\n ; ↳ 6" logior "Return the result of bitwise OR (inclusive OR) operation on integers.\n\nExamples:\n\n (logior)\n ; ↳ 0\n\n (logior 2)\n ; ↳ 2\n\n (logior 2 3)\n ; ↳ 3\n\n (logior 2 3 4)\n ; ↳ 7" cadr "Shorthand for `(car (cdr lst))`, that is, _first element of the\nsecond element_.\n\nExamples:\n\n (cadr '(1 2 3))\n ; ↳ 2\n\n (cadr '(1))\n ; ↳ NIL\n\n (cadr NIL)\n ; ↳ NIL" cdadr "Shorthand for (cdr (car (cdr lst)))." (doc
+group doc) "Writing and reading documentation." nan? "Return `T` if `v` is a floating point representation of NaN, either\nnegative or positive, `NIL` otherwise." caar "Shorthand for (car (car lst))." div0 "Return the quotient of the truncated division `a/n`.\n\nExamples:\n\n (div0 10 3)\n ; ↳ 3\n\n (div0 -10 3)\n ; ↳ -3\n\n (div0 -10 -3)\n ; ↳ 3\n\n (div0 10 -3)\n ; ↳ -3" set-syntax! "Associate a macro name with its application function." mod0 "Return the remainder of the truncated division `a/n`.\n\nExamples:\n\n (mod0 10 3)\n ; ↳ 1\n\n (mod0 -10 3)\n ; ↳ -1\n\n (mod0 -10 -3)\n ; ↳ -1\n\n (mod0 10 -3)\n ; ↳ 1" last-pair "Return the last cell (pair) of the list.\n\nExamples:\n\n (last-pair '(1 2 3))\n ; ↳ (3)\n\n (last-pair '(1 2 . 3))\n ; ↳ (2 . 3)" path-cwd "Return the full path to the current directory of the process, or\nchange it to the path specified with `to` argument." (doc
4" sym? "Return `T` if `v` is a symbol, `NIL` otherwise." defmacro "Define a new macro.\n\nExamples:\n\n (defmacro (inc! v)\n \"Increments and returns the value.\"\n :doc-group my-cool-macros\n :doc-see my-other-cool-macro\n (if (num? v)\n (1+ v)\n `(set! ,v (1+ ,v))))\n (inc! 1)\n ; ↳ 2\n (set! x 1)\n (inc! x)\n ; ↳ 2\n x\n ; ↳ 2" u64 "Construct a 64-bit unsigned number." Instructions "VM instructions mapped to their encoded byte representation." assv "Return a pair of a matching key and the associated value, or `NIL` if\nnone matched. Keys are compared using `eqv?`." bignum "Construct a bignum. As opposed to a fixnum, its value is not limited." copy-vec "Return a new copy of the vector with the elements.\n\nNo copies of the keys nor values are created - original ones are\nreused.\n\nExamples:\n\n (def v #vec(a (1 2 3)))\n (def q (copy-vec v))\n (eq? v q)\n ; ↳ NIL\n (equal? v q)\n ; ↳ T" *os-name* "The name of the operating system this StreetLISP VM executable was\nbuilt for.\n\nIt's set to a lowercase string and its value is considered \"best\neffort\" - it might not always be accurate.\n\nPossible values: `\"unknown\"`, `\"plan9\"`, `\"linux\"`, `\"openbsd\"`,\n`\"netbsd\"`, `\"dragonflybsd\"`, `\"freebsd\"`, `\"haiku\"`, `\"macosx\"`,\n`\"macos\"`, `\"dos\"`." eqv? "Return `T` if both `a` and `b` are of the same value and primitive\n(leaf) type, `NIL` otherwise. Neither cons cell nor vector are not\nconsidered primitive types as they may define deep structures.\n\nExamples:\n\n (eqv? 0.0 0)\n ; ↳ NIL\n\n (eqv? 0 0)\n ; ↳ T\n\n (def a \"1\")\n (def b \"1\")\n (eqv? a b)\n ; ↳ T\n\n (def a '(1))\n (def b '(1))\n (eqv? a b)\n ; ↳ NIL" list "Return a list constructed of the arguments.\n\nExamples:\n\n (list) ; empty list\n ; ↳ NIL\n\n (list 1 2.5 \"a\" 'b)\n ; ↳ (1 2.5 \"a\" b)" __init_globals "Initialize globals that need to be set at load time." rand-u32 "Return a random integer on interval [0, 2³²-1]." revappend "Return list with its elements in reverse order, with `tail` appended\nto its end.\n\nThe original list is copied to construct the reversed version.\n\nExamples:\n\n (def a '(4 5 6))\n (revappend a '(3 2 1))\n ; ↳ (6 5 4 3 2 1)\n a\n ; ↳ (4 5 6)" quote "Leave the expression unevaluated.\n\nShorthand for `(quote expr)`.\n\nExamples:\n\n '(0 1 (+ 2 3)) ; same as (quote (0 1 (+ 2 3)))\n ; ↳ (0 1 (+ 2 3))" nreconc "Return list with its elements in reverse order, with `tail` appended\nto its end.\n\nThe original list may be modified by this function.\n\nExamples:\n\n (def a '(4 5 6))\n (nreconc a '(3 2 1))\n ; ↳ (6 5 4 3 2 1)" defc*r "Define a shorthand for list access using `car` and `cdr`.\n\nExamples:\n\n (defc*r caaaaaaaaddr) ; define the function" (doc
group misc) "Miscellaneous." read-all-of "Call `fn` on an IO object until it runs out of data. Return the list\ncontaining the values returned by `fn` on each call." cddddr "Shorthand for (cdr (cdr (cdr (cdr lst))))." prog1 "Evaluate the expressions in order, return the result of the first one.\n\nExamples:\n\n (prog1 (+ 1 2 3)\n (print \"hi\")\n (newline))\n ; ↳ 6" logior "Return the result of bitwise OR (inclusive OR) operation on integers.\n\nExamples:\n\n (logior)\n ; ↳ 0\n\n (logior 2)\n ; ↳ 2\n\n (logior 2 3)\n ; ↳ 3\n\n (logior 2 3 4)\n ; ↳ 7" cadr "Shorthand for `(car (cdr lst))`, that is, _first element of the\nsecond element_.\n\nExamples:\n\n (cadr '(1 2 3))\n ; ↳ 2\n\n (cadr '(1))\n ; ↳ NIL\n\n (cadr NIL)\n ; ↳ NIL" cdadr "Shorthand for (cdr (car (cdr lst)))." (doc
group doc) "Writing and reading documentation." nan? "Return `T` if `v` is a floating point representation of NaN, either\nnegative or positive, `NIL` otherwise." caar "Shorthand for (car (car lst))." div0 "Return the quotient of the truncated division `a/n`.\n\nExamples:\n\n (div0 10 3)\n ; ↳ 3\n\n (div0 -10 3)\n ; ↳ -3\n\n (div0 -10 -3)\n ; ↳ 3\n\n (div0 10 -3)\n ; ↳ -3" set-syntax! "Associate a macro name with its application function." mod0 "Return the remainder of the truncated division `a/n`.\n\nExamples:\n\n (mod0 10 3)\n ; ↳ 1\n\n (mod0 -10 3)\n ; ↳ -1\n\n (mod0 -10 -3)\n ; ↳ -1\n\n (mod0 10 -3)\n ; ↳ 1" last-pair "Return the last cell (pair) of the list.\n\nExamples:\n\n (last-pair '(1 2 3))\n ; ↳ (3)\n\n (last-pair '(1 2 . 3))\n ; ↳ (2 . 3)" path-cwd "Return the full path to the current directory of the process, or\nchange it to the path specified with `to` argument." (doc
--- a/src/docs.sl
+++ b/src/docs.sl
@@ -1268,7 +1268,7 @@
(io-filename b)
; ↳ "new name"
- (def f (file "/dev/random" :read))
+ (def f (file "/dev/random"))
(io-filename f)
; ↳ "/dev/random"
(io-close f)
@@ -1278,3 +1278,21 @@
(io-filename *io-out*)
; ↳ "*stdout*"»
:doc-group io)
+
+(defdoc (io-close io)
+ «Close the IO object.
+
+ No further operations on the IO object are possible, those will throw
+ an exception if attempted. The only exception is `(io-filename io)`,
+ which might be useful in some cases for debugging purposes.
+
+ Examples:
+
+ (def f (file "/dev/random"))
+ (io-read f 'u8)
+ ; ↳ #u8(123)
+ (io-close f)
+ (io-read f 'u8)
+ ; ‼ I/O error: closed file»
+ :doc-group io
+ :doc-see file)
--
⑨