ref: dc6306e051c74dfa60865db0cc0bbf11b37aaecf
parent: 2ea6bcdad65dd4ccec777bfed3f4d796cf98424b
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Apr 27 13:18:02 EDT 2025
float → f32, double → f64
--- a/boot/sl.boot
+++ b/boot/sl.boot
@@ -12,7 +12,7 @@
#fn("n201m:" 6) NIL #fn("z0700}2:" #(vec) 6)
#fn("z0700}2:" #(aset!) 6) NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL #fn("n3012082>1|:" #(#fn("n1A061:" 6)) 7)
NIL NIL NIL NIL NIL NIL NIL NIL #fn("z0700}2:" #(aref) 6) NIL NIL)
- *properties* #table(*formals-list* #table(identity ((x)) bound? ((symbol)) sym-set-doc ((symbol
+ *properties* #table(*formals-list* #table(rand-f32 (NIL) bound? ((symbol)) identity ((x)) sym-set-doc ((symbol
doc-seq . formals-list)) odd? ((x)) list? ((a)) io-eof? ((io)) < ((a . rest)) cadr ((cell)) sym (term) nan? ((v)) for ((min
max fn)) fixnum? ((v)) exit (((status NIL))) assoc ((key lst)) > ((a . rest)) + (rest) div0 ((a
b)) __finish ((status)) lz-unpack ((data :to destination)
@@ -19,51 +19,47 @@
(data :size decompressed-bytes)) defstruct ((name docs…
options… (slot-1 DEFAULT) slot-2 slot-3)
(name (:type 'vec)
- (:named T) (:constructor T) (:conc-name T) (:predicate T) . slots)) compare ((x y)) buffer (NIL) num? ((v)) add-exit-hook ((fun)) assoc-list (kvs) rand-float (NIL) assert ((expr)) builtin? ((v)) set-car! ((cell
- new-first)) cons? ((v)) doc-group ((group-name doc)) 1+ ((n)) even? ((x)) aref ((sequence
+ (:named T) (:constructor T) (:conc-name T) (:predicate T) . slots)) compare ((x y)) buffer (NIL) num? ((v)) add-exit-hook ((fun)) assoc-list (kvs) assert ((expr)) builtin? ((v)) set-car! ((cell
+ new-first)) doc-group ((group-name doc)) cons? ((v)) 1+ ((n)) even? ((x)) aref ((sequence
subscript0 . rest)) zero? ((x)) vec (rest) >= ((a . rest)) sym? ((v)) void? ((x)) proper-list? ((a)) length= ((seq
n)) positive? ((x)) doc-for ((term . doc)) aset! ((sequence subscripts… new-value)) car ((lst)) <= ((a . rest)) str (term) cons ((first
second)) - ((a . rest)) remprop ((symbol key)) negative? ((x)) rand (NIL) void (rest) assert-fail ((expr . what)) file ((path
- (:read NIL) (:write NIL) (:create NIL) (:truncate NIL) (:append NIL))) rand-double (NIL) assv ((key
- lst)) 1- ((n)) atom? ((value)) cdr ((lst)) vec? ((v)) / ((x . rest)) equal? ((a b)) min ((x0 . xs)) eqv? ((a
- b)) io? ((term)) eof-object? ((term)) list (rest) apply ((fn arg . rest)) help ((term (kind
- NIL)
- (:print-header help-print-header))) memv ((item lst)) max ((x0 . xs)) rand-u32 (NIL) = ((a . rest)) rand-u64 (NIL) not ((v)) separate-doc-from-body ((body
- (doc NIL))) set-cdr! ((cell new-second)) fn? ((v)) help-print-header ((term sigs (:kind NIL)
- (:lpad ""))) lz-pack ((data
- (level 0))) *prompt* (NIL) member ((item lst)) eq? ((a b)) getprop ((symbol key (def NIL))) vm-stats (NIL) * (rest) putprop ((symbol
- key val)) io->str ((io))) *doc* #table(sym-set-doc "Set the documentation for the symbol." io-eof? "Return `T` if `io` is currently in the \"end of file\" state, `NIL`\notherwise." cadr "Shorthand for `(car (cdr cell))`, that is, _first element of the\nsecond element_.\n\nExamples:\n\n (cadr '(1 2 3)) → 2\n (cadr '(1)) → NIL\n (cadr NIL) → NIL" nan? "Return `T` if `v` is a floating point representation of NaN, either\nnegative or positive, `NIL` otherwise." 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." div0 "Return the quotient of two numbers. For non-integers this is\nequivalent to `(div0 (floor a) (floor b))`. The result is always an\ninteger.\n\nExamples:\n\n (div0 7 2) → 3\n (div0 10 -2) → -5\n (div0 6.9 1.9) → 6" (doc
+ (:read NIL) (:write NIL) (:create NIL) (:truncate NIL) (:append NIL))) assv ((key lst)) 1- ((n)) atom? ((value)) cdr ((lst)) vec? ((v)) / ((x . rest)) equal? ((a
+ b)) min ((x0 . xs)) eqv? ((a b)) io? ((term)) eof-object? ((term)) list (rest) apply ((fn
+ arg . rest)) help ((term (kind NIL) (:print-header help-print-header))) memv ((item lst)) max ((x0 . xs)) rand-u32 (NIL) = ((a . rest)) rand-u64 (NIL) not ((v)) separate-doc-from-body ((body
+ (doc NIL))) set-cdr! ((cell new-second)) fn? ((v)) rand-f64 (NIL) lz-pack ((data (level 0))) help-print-header ((term
+ sigs (:kind NIL) (:lpad ""))) member ((item lst)) eq? ((a b)) *prompt* (NIL) getprop ((symbol
+ key (def NIL))) putprop ((symbol key val)) vm-stats (NIL) * (rest) io->str ((io))) *doc* #table(sym-set-doc "Set the documentation for the symbol." io-eof? "Return `T` if `io` is currently in the \"end of file\" state, `NIL`\notherwise." cadr "Shorthand for `(car (cdr cell))`, that is, _first element of the\nsecond element_.\n\nExamples:\n\n (cadr '(1 2 3)) → 2\n (cadr '(1)) → NIL\n (cadr NIL) → NIL" nan? "Return `T` if `v` is a floating point representation of NaN, either\nnegative or positive, `NIL` otherwise." 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." div0 "Return the quotient of two numbers. For non-integers this is\nequivalent to `(div0 (floor a) (floor b))`. The result is always an\ninteger.\n\nExamples:\n\n (div0 7 2) → 3\n (div0 10 -2) → -5\n (div0 6.9 1.9) → 6" (doc
group prop) "Dealing with symbols' properties." lz-unpack "Return decompressed data previously compressed using lz-pack.\n\nEither destination for the decompressed data or the expected size of\nthe decompressed data must be specified. In the latter case a new\narray is allocated." defstruct "Defines a structure type with a specific 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\n\n (defstruct blah \"Return stuff.\" :doc-group stuff a b (c 1 :read-only T))\n\nGenerates the default constructor for a structure of three slots, with\nthe third (`c`) having a specific default value and being read-only.\n\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)" (doc
group compare) "Comparison operators." 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." 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." assoc-list "Return an association list built of 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) → ((a . 0) (b . 1))" 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)) → T\n (assert (eq? (str-rune s 0) #\\x)) → assertion failed: ..." builtin? "Return `T` if `v` is a built-in function implemented in C, `NIL`\notherwise.\n\nExamples:\n\n (builtin? map) → T\n (builtin? macroexpand) → NIL" set-car! "Modify a cons cell (a list) in-place by putting `new-first` as its\nfirst element (head of the list). Return the modified cons\ncell (list).\n\nExamples:\n\n (def q '(1 2 3 4 5))\n (set-car! q 0) → (0 6 7)\n q → (0 6 7)" (doc
group debug) "Debugging utilities." 1+ "Equivalent to `(+ n 1)`." vec "Return a vector constructed of the arguments.\n\nExamples:\n\n (vec) → #() ; empty vector\n (vec 1 2.5 \"a\" 'b) → #(1 2.5 \"a\" b)" positive? "Return `T` if `x` is greater than zero." *builtins* "VM instructions as closures." str "Return concatenation of terms formatted as strings.\n\nThis is equivalent to `(princ terms…)`, except the string is\nreturned, rather than printed.\n\nExamples:\n\n (str \"a\" 'b 1 #(0)) → \"ab1#(0)\"" remprop "Remove a property value associated with the symbol." negative? "Return `T` if `x` is negative." 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\nbe returned instead, in case of `#<void>` alone, REPL will not print\nit." assert-fail "Throw an \"assertion failed\" exception if evaluating `expr` itself does\nnot result in an exception thrown. Return `T` otherwise.\n\nTo test for a specific exception type, an optional `what` argument can\nbe used.\n\nExamples:\n\n (def s \"abc\")\n (assert-fail (= (length s) 3)) → assertion failed: ...\n (assert-fail (= s 1) type-error) → T" (doc
- group list) "Working with lists." file "Open a file for I/O.\n\nAn `io` object is returned. Without any modes specified the file\nis opened in read-only mode." rand-double "Return a random double on interval [0.0, 1.0]." 1- "Equivalent to `(- n 1)`." cdr "Return the second element of a cons cell (tail of a list) or `NIL` if\nnot available.\n\nExamples:\n\n (cdr NIL) → NIL\n (cdr '(1 2 3)) → (2 3)\n (cdr '(1 . 2)) → 2" atom? "Return `T` if `v` is a _not_ a cons cell, `NIL` otherwise. This is\nthe opposite of `cons?`.\n\nThe term \"atom\" comes from the idea of being indivisible.\n\nExamples:\n\n (atom? \"a\") → T\n (atom? NIL) → T\n (atom? '(1)) → NIL" / "Return the division of the arguments. With only one argument the\nresult of `1/x` is returned. If the result is integer-valued, it is\nreturned as an integer.\n\nExamples:\n\n (/ 2) → 0.5\n (/ 7 2 2) → 1.75\n (/ 10 -2) → -5 ; a fixnum\n (/ 6.9 1.9) → 3.6315…" 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) → NIL\n (equal? 0 0) → T\n (def a \"1\")\n (def b \"1\")\n (equal? a b) → T\n (def a '(1))\n (def b '(1))\n (equal? a b) → T" apply "Return the result of applying a function to a list of arguments.\n\nThe last argument must always be a list which gets spliced as\narguments to the function.\n\nExamples:\n\n (apply + 1 2 '(3 4 5)) → 15\n (apply vec '(1 2 3)) → #(3 4 5)\n (apply arr 'u8 '(3 4 5)) → #vu8(3 4 5)" separate-doc-from-body "Take a list of terms and return a pair `(doc . body)`, where the first\nelement contains a list of documentation-related terms, and the second\ncontains the rest of the terms." = "Numerical equality test. Return `T` if all numbers are equal,\n`NIL` otherwise." rand-u64 "Return a random integer on interval [0, 2⁶⁴-1]." (doc
- group sys) "OS-specific functions." not "Return `T` if `v` is `NIL`, `T` otherwise." 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)) → (1 6 7)\n q → (1 6 7)" fn? "Return `T` if `v` is a function, `NIL` otherwise.\n\nExamples:\n\n (fn? map) → T\n (fn? macroexpand) → T" lz-pack "Return data compressed using Lempel-Ziv.\n\nThe data must be an array, returned value will have the same type.\nThe optional `level` is between `0` and `10`. With `level` set to\n`0` a simple LZSS using hashing will be performed. Levels between\n`1` and `9` offer a trade-off between time/space and ratio. Level\n`10` is optimal but very slow." *prompt* "Function called by REPL to signal the user input is required.\n\nDefault function prints `#;> `." member "Return the tail of a list beginning with the item, or `NIL` otherwise.\nList elements are compared to the `item` using `equal?`.\n\nExamples:\n\n (member 1 '(3 2 1 0)) → (1 0)\n (member 1 '(2 3)) → NIL" eq? "Return `T` if `a` and `b` are the same object, `NIL` otherwise.\n\nExamples:\n\n (eq? 0.0 0) → NIL\n (eq? 0 0) → T\n (def a \"1\")\n (def b \"1\")\n (eq? a b) → NIL\n (def a '(1))\n (def b '(1))\n (eq? a b) → NIL" getprop "Return a property value associated with the symbol or `def` if\nmissing." vm-stats "Print various VM-related information, such as the number of GC\ncalls so far, heap and stack size, etc." * "Return product of the arguments or `1` when none specified." putprop "Associate a property value with the symbol." io->str "Return an in-memory `io` buffer converted to a string." bound? "Return `T` if `symbol` has a value associated with it, `NIL` otherwise." odd? "Return `T` if `x` is an odd integer, `NIL` otherwise." list? "Return `T` if the value is either `NIL` or a cons cell, `NIL`\notherwise." (doc
+ group list) "Working with lists." file "Open a file for I/O.\n\nAn `io` object is returned. Without any modes specified the file\nis opened in read-only mode." 1- "Equivalent to `(- n 1)`." cdr "Return the second element of a cons cell (tail of a list) or `NIL` if\nnot available.\n\nExamples:\n\n (cdr NIL) → NIL\n (cdr '(1 2 3)) → (2 3)\n (cdr '(1 . 2)) → 2" atom? "Return `T` if `v` is a _not_ a cons cell, `NIL` otherwise. This is\nthe opposite of `cons?`.\n\nThe term \"atom\" comes from the idea of being indivisible.\n\nExamples:\n\n (atom? \"a\") → T\n (atom? NIL) → T\n (atom? '(1)) → NIL" / "Return the division of the arguments. With only one argument the\nresult of `1/x` is returned. If the result is integer-valued, it is\nreturned as an integer.\n\nExamples:\n\n (/ 2) → 0.5\n (/ 7 2 2) → 1.75\n (/ 10 -2) → -5 ; a fixnum\n (/ 6.9 1.9) → 3.6315…" 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) → NIL\n (equal? 0 0) → T\n (def a \"1\")\n (def b \"1\")\n (equal? a b) → T\n (def a '(1))\n (def b '(1))\n (equal? a b) → T" apply "Return the result of applying a function to a list of arguments.\n\nThe last argument must always be a list which gets spliced as\narguments to the function.\n\nExamples:\n\n (apply + 1 2 '(3 4 5)) → 15\n (apply vec '(1 2 3)) → #(3 4 5)\n (apply arr 'u8 '(3 4 5)) → #vu8(3 4 5)" separate-doc-from-body "Take a list of terms and return a pair `(doc . body)`, where the first\nelement contains a list of documentation-related terms, and the second\ncontains the rest of the terms." = "Numerical equality test. Return `T` if all numbers are equal,\n`NIL` otherwise." rand-u64 "Return a random integer on interval [0, 2⁶⁴-1]." (doc
+ group sys) "OS-specific functions." not "Return `T` if `v` is `NIL`, `T` otherwise." 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)) → (1 6 7)\n q → (1 6 7)" fn? "Return `T` if `v` is a function, `NIL` otherwise.\n\nExamples:\n\n (fn? map) → T\n (fn? macroexpand) → T" lz-pack "Return data compressed using Lempel-Ziv.\n\nThe data must be an array, returned value will have the same type.\nThe optional `level` is between `0` and `10`. With `level` set to\n`0` a simple LZSS using hashing will be performed. Levels between\n`1` and `9` offer a trade-off between time/space and ratio. Level\n`10` is optimal but very slow." *prompt* "Function called by REPL to signal the user input is required.\n\nDefault function prints `#;> `." member "Return the tail of a list beginning with the item, or `NIL` otherwise.\nList elements are compared to the `item` using `equal?`.\n\nExamples:\n\n (member 1 '(3 2 1 0)) → (1 0)\n (member 1 '(2 3)) → NIL" eq? "Return `T` if `a` and `b` are the same object, `NIL` otherwise.\n\nExamples:\n\n (eq? 0.0 0) → NIL\n (eq? 0 0) → T\n (def a \"1\")\n (def b \"1\")\n (eq? a b) → NIL\n (def a '(1))\n (def b '(1))\n (eq? a b) → NIL" getprop "Return a property value associated with the symbol or `def` if\nmissing." vm-stats "Print various VM-related information, such as the number of GC\ncalls so far, heap and stack size, etc." * "Return product of the arguments or `1` when none specified." putprop "Associate a property value with the symbol." io->str "Return an in-memory `io` buffer converted to a string." rand-f32 "Return a random 32-bit floating pointer number on [0.0, 1.0] interval." bound? "Return `T` if `symbol` has a value associated with it, `NIL` otherwise." odd? "Return `T` if `x` is an odd integer, `NIL` otherwise." list? "Return `T` if the value is either `NIL` or a cons cell, `NIL`\notherwise." (doc
group io) "I/O functionality." < "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`." sym "Return a symbol with the name being the concatenation of terms\nformatted as strings.\n\nThis is equivalent to `(sym (str terms…))`.\n\nExamples:\n\n (sym \"a\" 'b 1) → ab1" (doc
group builtin) "Built-in operators." NIL "An empty list. Can be used as the opposite of T in boolean\nexpressions.\n\nExamples:\n\n (not NIL) → T\n (if NIL 'yes 'no) → no\n (car NIL) → NIL\n (cdr NIL) → NIL" for "Call the function `fn` with a single integer argument, starting from\n`min` and ending with `max`.\n\nExamples:\n\n (for 0 2 (λ (i) (print (- 2 i)))) → 210" (doc
group vm) "VM-related functions." assoc "Return a pair of a matching key and the associated value, or `NIL` if\nnone matched. Keys are compared using `equal?`.\n\nExamples:\n\n (def L (assoc-list 'a 0 'b 1))\n (assoc 'b L) → (b . 1)\n (assoc 'c L) → NIL" > "Return `T` if the arguments are in strictly decreasing order (previous\none is greater than the next one)." + "Return sum of the arguments or `0` when none specified." (doc
- group rand) "Random numbers generation." compare "Return -1 if `x` is less than `y`, 0 if equal, and `1` if `y` is\ngreater than `x`.\n\nExamples:\n\n (compare 'a 'b) → -1\n (compare 1 1) → 0\n (compare \"b\" \"a\") → 1" add-exit-hook "Puts an one-argument function on top of the list of exit hooks.\n\nOn shutdown each exit hook is called with the exit status as a single\nargument, which is (usually) `NIL` on success and a string describing\nan error otherwise." rand-float "Return a random float on [0.0, 1.0] interval." doc-group "Define documentation for a group." cons? "Return `T` if `v` is a cons cell, `NIL` otherwise.\n\nExamples:\n\n (cons? 0) → NIL\n (cons? NIL) → NIL\n (cons? '(1)) → T" even? "Return `T` if `x` is an even integer, `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) → (1 (2 (3)) 4)\n (aref a 1) → index 1 out of bounds\n (aref a 0 0) → 1\n (aref a 0 1 0) → 2\n (aref a 0 2) → 4" *properties* "All properties of symbols recorded with `putprop` are recorded in this\ntable." zero? "Return `T` if `x` is zero." >= "Return `T` if the arguments are in non-increasing order (previous\none is greater than or equal to the next one)." sym? "Return `T` if `v` is a symbol, `NIL` otherwise." void? "Return `T` if `x` is `#<void>`, `NIL` otherwise." proper-list? "Return `T` is the value is a proper list. That is, a non-circular\nlist with the last element being `NIL`, as opposed to a dotted list.\n\nExamples:\n\n (proper-list? NIL) → T\n (proper-list? '(1)) → T\n (proper-list? '(1 . 2) → NIL\n (def l '(1))\n (set-cdr! l l) → #0=(1 . #0#)\n (length l) → +inf.0\n (proper-list? l) → NIL" length= "Perform a bounded length test.\n\nUse this instead of `(= (length seq) n)`, since it avoids unnecessary\nwork and always terminates." doc-for "Define documentation for a top level term.\n\nIf `term` is a function signature and `doc` is not specified, just\nthe signature will be included in the documentation, without\nreplacing any previously defined.\n\nFirst `doc` argument is supposed to be a string with the description\nof the term. The following arguments are expected to be optional tag\npairings that provide grouping for multiple symbols and \"see also\"\nreferences.\n\nUseful in cases where setting the documentation for a term can't\n(or not preferred to) be made during the definition of said term.\nOne of those reasons is that the term is a built-in function\nimplemented in C.\n\nExamples:\n\n (doc-for (func arg (arg2 0))\n \"Return something about the `arg` and `arg2`. This is a short\n description.\n\n This is the longer description, following the short one.\n\n Examples:\n\n (func 0) → T\n (func 1 3) → NIL\"\n :doc-group stuff\n :doc-see func2)\n (doc-for (func arg (:another-variant NIL)))" 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) → index 1 out of bounds\n (aset! a 0 0 'x) → x\n a → ((x #(2 (3)) 4))\n (aset! a 0 1 9) → 9\n a → ((x #(9 (3)) 4))" T "A boolean \"true\".\n\nExamples:\n\n (not T) → NIL\n (if T 'yes 'no) → yes" car "Return the first element of a cons cell (head of a list) or `NIL` if\nnot available.\n\nExamples:\n\n (car NIL) → NIL\n (car '(1 2 3)) → 1\n (car '(1 . 2)) → 1" <= "Return `T` if the arguments are in non-decreasing order (previous\none is less than or equal to the next one)." cons "Return a cons cell containing two arguments.\n\nExamples:\n\
\ No newline at end of file
+ group rand) "Random numbers generation." compare "Return -1 if `x` is less than `y`, 0 if equal, and `1` if `y` is\ngreater than `x`.\n\nExamples:\n\n (compare 'a 'b) → -1\n (compare 1 1) → 0\n (compare \"b\" \"a\") → 1" add-exit-hook "Puts an one-argument function on top of the list of exit hooks.\n\nOn shutdown each exit hook is called with the exit status as a single\nargument, which is (usually) `NIL` on success and a string describing\nan error otherwise." doc-group "Define documentation for a group." cons? "Return `T` if `v` is a cons cell, `NIL` otherwise.\n\nExamples:\n\n (cons? 0) → NIL\n (cons? NIL) → NIL\n (cons? '(1)) → T" even? "Return `T` if `x` is an even integer, `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) → (1 (2 (3)) 4)\n (aref a 1) → index 1 out of bounds\n (aref a 0 0) → 1\n (aref a 0 1 0) → 2\n (aref a 0 2) → 4" *properties* "All properties of symbols recorded with `putprop` are recorded in this\ntable." zero? "Return `T` if `x` is zero." >= "Return `T` if the arguments are in non-increasing order (previous\none is greater than or equal to the next one)." sym? "Return `T` if `v` is a symbol, `NIL` otherwise." void? "Return `T` if `x` is `#<void>`, `NIL` otherwise." proper-list? "Return `T` is the value is a proper list. That is, a non-circular\nlist with the last element being `NIL`, as opposed to a dotted list.\n\nExamples:\n\n (proper-list? NIL) → T\n (proper-list? '(1)) → T\n (proper-list? '(1 . 2) → NIL\n (def l '(1))\n (set-cdr! l l) → #0=(1 . #0#)\n (length l) → +inf.0\n (proper-list? l) → NIL" length= "Perform a bounded length test.\n\nUse this instead of `(= (length seq) n)`, since it avoids unnecessary\nwork and always terminates." doc-for "Define documentation for a top level term.\n\nIf `term` is a function signature and `doc` is not specified, just\nthe signature will be included in the documentation, without\nreplacing any previously defined.\n\nFirst `doc` argument is supposed to be a string with the description\nof the term. The following arguments are expected to be optional tag\npairings that provide grouping for multiple symbols and \"see also\"\nreferences.\n\nUseful in cases where setting the documentation for a term can't\n(or not preferred to) be made during the definition of said term.\nOne of those reasons is that the term is a built-in function\nimplemented in C.\n\nExamples:\n\n (doc-for (func arg (arg2 0))\n \"Return something about the `arg` and `arg2`. This is a short\n description.\n\n This is the longer description, following the short one.\n\n Examples:\n\n (func 0) → T\n (func 1 3) → NIL\"\n :doc-group stuff\n :doc-see func2)\n (doc-for (func arg (:another-variant NIL)))" 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) → index 1 out of bounds\n (aset! a 0 0 'x) → x\n a → ((x #(2 (3)) 4))\n (aset! a 0 1 9) → 9\n a → ((x #(9 (3)) 4))" T "A boolean \"true\".\n\nExamples:\n\n (not T) → NIL\n (if T 'yes 'no) → yes" car "Return the first element of a cons cell (head of a list) or `NIL` if\nnot available.\n\nExamples:\n\n (car NIL) → NIL\n (car '(1 2 3)) → 1\n (car '(1 . 2)) → 1" <= "Return `T` if the arguments are in non-decreasing order (previous\none is less than or equal to the next one)." cons "Return a cons cell containing two arguments.\n\nExamples:\n\n (cons 1 2) → (1 . 2)\n (cons 1
\ No newline at end of file
n (cons 1 2) → (1 . 2)\n (cons 1 '(2)) → (1 2)\n (cons 1 (cons 2 (cons 3 NIL))) → (1 2 3)" - "Return the result of subtraction. With only one argument a\nnegation is performed.\n\nExamples:\n\n (- 1.5) → -1.5\n (- 3 2) → 1" rand "Return a random non-negative fixnum on its maximum range." 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?`." (doc
-"Return a list constructed of the arguments.\n\nExamples:\n\n (list) → NIL ; empty list\n (list 1 2.5 \"a\" 'b) → (1 2.5 \"a\" b)" help "Display documentation the specified term, if available.\n\nThe optional parameter `kind` can be set to `group` to show\ndocumentation for the specified group instead of a single term.\nAll available documentation groups can be displayed with `(help\ngroups)`." memv "Return the tail of a list beginning with the item, or `NIL` otherwise.\nList elements are compared to the `item` using `eqv?`." (doc
- group doc) "Writing and reading documentation." max "Return the largest among the arguments.\n\nExamples:\n\n (max 3 1 9 4) → 9\n (max 'c 'h 'z 'a) → z\n (max \"t\" \"g\" \"a\") → \"t\"" rand-u32 "Return a random integer on interval [0, 2³²-1]." help-print-header "Format and print signature(s) of the term for `(help term)` output." arg-counts "VM instructions mapped to their expected arguments count." (doc
+n (list) → NIL ; empty list\n (list 1 2.5 \"a\" 'b) → (1 2.5 \"a\" b)" help "Display documentation the specified term, if available.\n\nThe optional parameter `kind` can be set to `group` to show\ndocumentation for the specified group instead of a single term.\nAll available documentation groups can be displayed with `(help\ngroups)`." memv "Return the tail of a list beginning with the item, or `NIL` otherwise.\nList elements are compared to the `item` using `eqv?`." (doc
+ group doc) "Writing and reading documentation." max "Return the largest among the arguments.\n\nExamples:\n\n (max 3 1 9 4) → 9\n (max 'c 'h 'z 'a) → z\n (max \"t\" \"g\" \"a\") → \"t\"" rand-u32 "Return a random integer on interval [0, 2³²-1]." rand-f64 "Return a random 64-bit floating point number on interval [0.0, 1.0]." help-print-header "Format and print signature(s) of the term for `(help term)` output." arg-counts "VM instructions mapped to their expected arguments count." (doc
max "Return the largest among the arguments.\n\nExamples:\n\n (max 3 1 9 4) → 9\n (max 'c 'h 'z 'a) → z\n (max \"t\" \"g\" \"a\") → \"t\"" rand-u32 "Return a random integer on interval [0, 2³²-1]." help-print-header "Format and print signature(s) of the term for `(help term)` output." arg-counts "VM instructions mapped to their expected arguments count." (doc
group compress) "Compression." identity "Return `x`.") *doc-extra* #table(bound? ((:doc-group . builtin)) sym-set-doc ((:doc-group . doc)) odd? ((:doc-group . compare)
(:doc-see . even?)) list? ((:doc-group . list) (:doc-see . proper-list?)) io-eof? ((:doc-group . io)) < ((:doc-group . compare)
-(:doc-group . io)) < ((:doc-group . compare)
- (:doc-group . builtin)) cadr ((:doc-group . list) (:doc-group . builtin)) nan? ((:doc-group . builtin)) NIL ((:doc-see . T)) for ((:doc-group . builtin)) fixnum? ((:doc-group . builtin)) exit ((:doc-group . sys)) assoc ((:doc-group . list)
+. builtin)) cadr ((:doc-group . list) (:doc-group . builtin)) nan? ((:doc-group . builtin)) NIL ((:doc-see . T)) for ((:doc-group . builtin)) fixnum? ((:doc-group . builtin)) exit ((:doc-group . sys)) assoc ((:doc-group . list)
doc-group . sys)) assoc ((:doc-group . list)
(:doc-see . assv)) > ((:doc-group . compare)) + ((:doc-group . builtin)) div0 ((:doc-group . builtin)) lz-unpack ((:doc-group . compress)) compare ((:doc-group . builtin)) buffer ((:doc-group . io)) num? ((:doc-group . builtin)) assert ((:doc-group . debug)
(:doc-see . assert-fail)) rand-float ((:doc-group . rand)) builtin? ((:doc-group . builtin)) set-car! ((:doc-group . list)
(:doc-group . builtin)) cons? ((:doc-group . builtin)) doc-group ((:doc-group . doc)) even? ((:doc-group . compare)
-oc-group . list)
- (:doc-see . list?)) length= ((:doc-group . list) (:doc-see . length>)) positive? ((:doc-group . compare)) doc-for ((:doc-group . doc)) aset! ((:doc-group . builtin)) T ((:doc-see)) car ((:doc-group . list)
+ . list) (:doc-see . length>)) positive? ((:doc-group . compare)) doc-for ((:doc-group . doc)) aset! ((:doc-group . builtin)) T ((:doc-see)) car ((:doc-group . list)
+ (:doc-group . builtin)) *builtins* ((:doc-group . builtin)) str ((:doc-group . string)) cons ((:doc-group . list)
ist)
(:doc-group . builtin)) - ((:doc-group . builtin)) remprop ((:doc-group . prop)) <= ((:doc-group . compare)) rand ((:doc-group . rand)) negative? ((:doc-group . compare)) assert-fail ((:doc-group . debug)
(:doc-see . assert)) Instructions ((:doc-group . builtin)) file ((:doc-group . io)) rand-double ((:doc-group . rand)) assv ((:doc-group . list)
(:doc-see . assoc)) cdr ((:doc-group . list) (:doc-group . builtin)) atom? ((:doc-group . builtin)) vec? ((:doc-group . builtin)) / ((:doc-group . builtin)) equal? ((:doc-group . compare)
- (:doc-group . builtin)) io? ((:doc-group . io)) eof-object? ((:doc-group . io)) list ((:doc-group . builtin)) apply ((:doc-group . builtin)) help ((:doc-group . doc)) memv ((:doc-group . list)
- (:doc-see . member)) max ((:doc-group . compare) (:doc-see . min)) rand-u32 ((:doc-group . rand)) = ((:doc-group . compare)
- (:doc-group . builtin)) rand-u64 ((:doc-group . rand)) not ((:doc-group . builtin)) separate-doc-from-body ((:doc-group . doc)) set-cdr! ((:doc-group . list)
- (:doc-group . builtin)) fn? ((:doc-group . builtin)) help-print-header ((:doc-group . doc)) lz-pack ((:doc-group . compress)) arg-counts ((:doc-group . builtin)) member ((:doc-group . list)
+ (:doc-group . builtin)) io? ((:doc-group . io)) eof-object? ((:doc-group . io)) list ((:doc-group . builtin)) apply ((:doc-group . builtin)) help ((:doc-group . doc)) memv ((:doc-group . list)
+ (:doc-see . member)) max ((:doc-group . compare) (:doc-see . min)) rand-u32 ((:doc-group . rand)) = ((:doc-group . compare)
+ (:doc-group . builtin)) rand-u64 ((:doc-group . rand)) not ((:doc-group . builtin)) separate-doc-from-body ((:doc-group . doc)) set-cdr! ((:doc-group . list)
+ (:doc-group . builtin)) fn? ((:doc-group . builtin)) rand-f64 ((:doc-group . rand)) lz-pack ((:doc-group . compress)) arg-counts ((:doc-group . builtin)) help-print-header ((:doc-group . doc)) eq? ((:doc-group . compare)
roup . list)
(:doc-group . builtin)) fn? ((:doc-group . builtin)) help-print-header ((:doc-group . doc)) lz-pack ((:doc-group . compress)) arg-counts ((:doc-group . builtin)) member ((:doc-group . list)
(:doc-see . memv)) eq? ((:doc-group . compare) (:doc-group . builtin)) getprop ((:doc-group . prop)
@@ -458,7 +454,7 @@
printable? #fn("n120051;JB0471051;J80422051S:" #(#fn(io?) void? #fn(eof-object?)) printable? 6)
proper-list? #fn("n1Ib520852185>1_5140S;JA040B;3:0485<0062:" #(#0#
#fn("n20=1=87B38087=@408786B3I088B3C08688QJ;0A<868862:86S;J60486B;360488S:" #() proper? 10)) proper-list? 8)
-868862:86S;J60486B;360488S:" #() proper? 10)) proper-list? 8)
+)
) proper-list? 8)
putprop #fn("n320711q5387360q@F02250237118853488?7^14238708253482:" #(#fn(get)
*properties* #fn(table)
--- a/src/builtins.c
+++ b/src/builtins.c
@@ -95,7 +95,7 @@
v2 = cdr_(v2);
}while(iscons(v) && iscons(v2) && v != v2);
if(iscons(v2))
- return mk_double(D_PINF);
+ return mk_f64(D_PINF);
n += llength(v);
return size_wrap(n);
}
@@ -226,10 +226,10 @@
return sl_t;
if(iscvalue(v)){
sl_numtype nt = cv_numtype(ptr(v));
- if(nt < T_FLT)
+ if(nt < T_F32)
return sl_t;
void *data = cv_data(ptr(v));
- if(nt == T_FLT){
+ if(nt == T_F32){
float f = *(float*)data;
if(f < 0)
f = -f;
@@ -236,7 +236,7 @@
if(f <= FLT_MAXINT && (float)(s32int)f == f)
return sl_t;
}else{
- assert(nt == T_DBL);
+ assert(nt == T_F64);
double d = *(double*)data;
if(d < 0)
d = -d;
@@ -253,7 +253,7 @@
argcount(nargs, 1);
sl_v v = args[0];
return (isfixnum(v) || isubnum(v) ||
- (iscvalue(v) && cv_numtype(ptr(v)) < T_FLT)) ?
+ (iscvalue(v) && cv_numtype(ptr(v)) < T_F32)) ?
sl_t : sl_nil;
}
@@ -305,9 +305,9 @@
sl_numtype nt = cv_numtype(cv);
double d;
if(valid_numtype(nt)){
- if(nt == T_FLT)
+ if(nt == T_F32)
d = (double)*(float*)data;
- else if(nt == T_DBL)
+ else if(nt == T_F64)
d = *(double*)data;
else
return v;
@@ -345,7 +345,7 @@
{
argcount(nargs, 0);
USED(args);
- return mk_double(sec_realtime());
+ return mk_f64(sec_realtime());
}
BUILTIN("nanoseconds-monotonic", nanoseconds_monotonic)
@@ -387,7 +387,7 @@
s64int it = (s64int)t;
if((double)it == t && fits_fixnum(it))
return fixnum(it);
- return mk_double(t);
+ return mk_f64(t);
}
BUILTIN("path-cwd", path_cwd)
--- a/src/cvalues.c
+++ b/src/cvalues.c
@@ -236,6 +236,8 @@
typedef u32int u32ptr;
typedef u64int u64ptr;
+typedef float f32;
+typedef double f64;
num_init(s8int, s32, T_S8)
num_init(u8int, u32, T_U8)
@@ -247,8 +249,8 @@
num_init(u64int, u64, T_U64)
num_init(u32ptr, p32, T_P32)
num_init(u64ptr, p64, T_P64)
-num_init(float, double, T_FLT)
-num_init(double, double, T_DBL)
+num_init(f32, double, T_F32)
+num_init(f64, double, T_F64)
BUILTIN("rune", rune)
{
@@ -341,8 +343,8 @@
num_ctor_unboxed(u64, u64int, T_U64)
num_ctor_unboxed(p32, u32ptr, T_P32)
num_ctor_unboxed(p64, u64ptr, T_P64)
-num_ctor(float, float, T_FLT)
-num_ctor(double, double, T_DBL)
+num_ctor(f32, f32, T_F32)
+num_ctor(f64, f64, T_F64)
num_ctor_init(utf8, u8int, T_U8)
static void
@@ -996,8 +998,8 @@
if(num_to_ptr(n, &pi, &pt, &a)){
switch(pt){
- case T_DBL: return mk_double(-*(double*)a);
- case T_FLT: return mk_float(-*(float*)a);
+ case T_F64: return mk_f64(-*(double*)a);
+ case T_F32: return mk_f32(-*(float*)a);
case T_S8: return fixnum(-(sl_fx)*(s8int*)a);
case T_U8: return fixnum(-(sl_fx)*(u8int*)a);
case T_S16: return fixnum(-(sl_fx)*(s16int*)a);
@@ -1093,7 +1095,7 @@
cthrow(type_error("b", "num", b), a);
return 2;
}
- if(eq && eqnans && ((ta >= T_FLT) != (tb >= T_FLT)))
+ if(eq && eqnans && ((ta >= T_F32) != (tb >= T_F32)))
return 1;
if(cmp_eq(aptr, ta, bptr, tb, eqnans))
return 0;
@@ -1131,14 +1133,14 @@
da = conv_to_double(a, aptr, ta);
db = conv_to_double(b, bptr, tb);
- if(db == 0 && tb < T_FLT) // exact 0
+ if(db == 0 && tb < T_F32) // exact 0
cthrow(divide_by_0_error(), a);
da = da/db;
- if(ta < T_FLT && tb < T_FLT && (double)(s64int)da == da)
+ if(ta < T_F32 && tb < T_F32 && (double)(s64int)da == da)
return return_from_s64((s64int)da);
- return mk_double(da);
+ return mk_f64(da);
}
sl_v
@@ -1214,9 +1216,9 @@
mpint *bmp = nil, *resmp = nil;
s64int b64;
- if(!num_to_ptr(a, &ai, &ta, &aptr) || ta >= T_FLT)
+ if(!num_to_ptr(a, &ai, &ta, &aptr) || ta >= T_F32)
cthrow(type_error("a", "int", a), a);
- if(!num_to_ptr(b, &bi, &tb, &bptr) || tb >= T_FLT)
+ if(!num_to_ptr(b, &bi, &tb, &bptr) || tb >= T_F32)
cthrow(type_error("b", "int", b), a);
if(ta < tb){
@@ -1249,8 +1251,8 @@
case T_P32: return mk_p32(*(u32int*)aptr & (u32int)b64);
case T_P64: return mk_p64(*(u64int*)aptr & (u64int)b64);
case T_BIG: mpand(*(mpint**)aptr, bmp, resmp); return mk_bignum(resmp);
- case T_FLT:
- case T_DBL: break;
+ case T_F32:
+ case T_F64: break;
}
break;
case 1:
@@ -1266,8 +1268,8 @@
case T_P32: return mk_p32(*(u32int*)aptr | (u32int)b64);
case T_P64: return mk_p64(*(u64int*)aptr | (u64int)b64);
case T_BIG: mpor(*(mpint**)aptr, bmp, resmp); return mk_bignum(resmp);
- case T_FLT:
- case T_DBL: break;
+ case T_F32:
+ case T_F64: break;
}
break;
case 2:
@@ -1283,8 +1285,8 @@
case T_P32: return mk_p32(*(u32int*)aptr ^ (u32int)b64);
case T_P64: return mk_p64(*(u64int*)aptr ^ (u64int)b64);
case T_BIG: mpxor(*(mpint**)aptr, bmp, resmp); return mk_bignum(resmp);
- case T_FLT:
- case T_DBL: break;
+ case T_F32:
+ case T_F64: break;
}
}
abort();
@@ -1420,7 +1422,7 @@
return mk_p32((*(u32int*)aptr)<<n);
else if(ta == T_P64)
return mk_p64((*(u64int*)aptr)<<n);
- else if(ta < T_FLT)
+ else if(ta < T_F32)
return return_from_s64(conv_to_s64(a, aptr, ta)<<n);
}
if(mp != nil){
@@ -1460,8 +1462,8 @@
ctor_cv_intern(u64, T_U64, u64int);
ctor_cv_intern(p32, T_P32, u32int);
ctor_cv_intern(p64, T_P64, u64int);
- ctor_cv_intern(float, T_FLT, float);
- ctor_cv_intern(double, T_DBL, double);
+ ctor_cv_intern(f32, T_F32, float);
+ ctor_cv_intern(f64, T_F64, double);
ctor_cv_intern(utf8, T_U8, u8int);
ctor_cv_intern(arr, NONNUMERIC, int);
@@ -1476,8 +1478,8 @@
mk_primtype(u64, u64int);
mk_primtype(p32, u32ptr);
mk_primtype(p64, u64ptr);
- mk_primtype(float, float);
- mk_primtype(double, double);
+ mk_primtype(f32, f32);
+ mk_primtype(f64, f64);
mk_primtype(utf8, u8int);
sl_ptrsym = mk_csym("ptr");
--- a/src/cvalues.h
+++ b/src/cvalues.h
@@ -52,8 +52,8 @@
sl_v mk_p32(u32int n);
sl_v mk_p64(u64int n);
sl_v mk_bignum(mpint *n);
-sl_v mk_float(float n);
-sl_v mk_double(double n);
+sl_v mk_f32(float n);
+sl_v mk_f64(double n);
usize llength(sl_v v) sl_purefn;
--- a/src/docs.sl
+++ b/src/docs.sl
@@ -97,12 +97,12 @@
"Return a random integer on interval [0, 2³²-1]."
:doc-group rand)
-(doc-for (rand-double)
- "Return a random double on interval [0.0, 1.0]."
+(doc-for (rand-f64)
+ "Return a random 64-bit floating point number on interval [0.0, 1.0]."
:doc-group rand)
-(doc-for (rand-float)
- "Return a random float on [0.0, 1.0] interval."
+(doc-for (rand-f32)
+ "Return a random 32-bit floating pointer number on [0.0, 1.0] interval."
:doc-group rand)
(doc-group sys
--- a/src/math.c
+++ b/src/math.c
@@ -5,7 +5,7 @@
BUILTIN(lname, cname) \
{ \
argcount(nargs, 1); \
- return mk_double(cname(todouble(args[0]))); \
+ return mk_f64(cname(todouble(args[0]))); \
}
BUILTIN_("sqrt", sqrt)
@@ -29,7 +29,7 @@
BUILTIN(lname, cname) \
{ \
argcount(nargs, 2); \
- return mk_double(cname(todouble(args[0]), todouble(args[1]))); \
+ return mk_f64(cname(todouble(args[0]), todouble(args[1]))); \
}
BUILTIN_("expt", pow)
--- a/src/operators.c
+++ b/src/operators.c
@@ -14,8 +14,8 @@
case T_S64: return vtomp(*(s64int*)data, nil);
case T_U64: case T_P64: return uvtomp(*(u64int*)data, nil);
case T_BIG: return mpcopy(*(mpint**)data);
- case T_FLT: return dtomp(*(float*)data, nil);
- case T_DBL: return dtomp(*(double*)data, nil);
+ case T_F32: return dtomp(*(float*)data, nil);
+ case T_F64: return dtomp(*(double*)data, nil);
}
cthrow(type_error(nil, "num", v), v);
}
@@ -39,8 +39,8 @@
return d;
case T_U64: case T_P64: return *(u64int*)data;
case T_BIG: return mptod(*(mpint**)data);
- case T_FLT: return *(float*)data;
- case T_DBL: return *(double*)data;
+ case T_F32: return *(float*)data;
+ case T_F64: return *(double*)data;
}
cthrow(type_error(nil, "num", v), v);
}
@@ -61,8 +61,8 @@
case T_S64: case T_P64: return (ctype)*(s64int*)data; \
case T_U64: return (ctype)*(u64int*)data; \
case T_BIG: return (ctype)mptov(*(mpint**)data); \
- case T_FLT: return (ctype)*(float*)data; \
- case T_DBL: return (ctype)*(double*)data; \
+ case T_F32: return (ctype)*(float*)data; \
+ case T_F64: return (ctype)*(double*)data; \
} \
cthrow(type_error(nil, "num", v), v); \
}
@@ -89,12 +89,12 @@
case T_S64: return *(s64int*)data; break;
case T_U64: case T_P64: return *(u64int*)data; break;
case T_BIG: return mptouv(*(mpint**)data); break;
- case T_FLT:
+ case T_F32:
if(*(float*)data >= 0)
return *(float*)data;
s = *(float*)data;
return s;
- case T_DBL:
+ case T_F64:
if(*(double*)data >= 0)
return *(double*)data;
s = *(double*)data;
@@ -117,8 +117,8 @@
case T_S64: return *(s64int*)a < *(s64int*)b;
case T_U64: case T_P64: return *(u64int*)a < *(u64int*)b;
case T_BIG: return mpcmp(*(mpint**)a, *(mpint**)b) < 0;
- case T_FLT: return *(float*)a < *(float*)b;
- case T_DBL: return *(double*)a < *(double*)b;
+ case T_F32: return *(float*)a < *(float*)b;
+ case T_F64: return *(double*)a < *(double*)b;
}
return false;
}
@@ -137,8 +137,8 @@
case T_S64: return *(s64int*)a == *(s64int*)b;
case T_U64: case T_P64: return *(u64int*)a == *(u64int*)b;
case T_BIG: return mpcmp(*(mpint**)a, *(mpint**)b) == 0;
- case T_FLT: return *(float*)a == *(float*)b && !isnan(*(float*)a);
- case T_DBL: return *(double*)a == *(double*)b && !isnan(*(double*)b);
+ case T_F32: return *(float*)a == *(float*)b && !isnan(*(float*)a);
+ case T_F64: return *(double*)a == *(double*)b && !isnan(*(double*)b);
}
return false;
}
@@ -171,7 +171,7 @@
if(atag == T_U64){
if(btag == T_S64)
return *(s64int*)b >= 0 && *(u64int*)a < (u64int)*(s64int*)b;
- if(btag == T_DBL)
+ if(btag == T_F64)
return db >= 0 ? *(u64int*)a < (u64int)*(double*)b : 0;
if(btag == T_BIG)
return mpcmp(uvtomp(*(u64int*)a, cmpmpint), *(mpint**)b) < 0;
@@ -179,19 +179,19 @@
if(atag == T_S64){
if(btag == T_U64)
return *(s64int*)a >= 0 && (u64int)*(s64int*)a < *(u64int*)b;
- if(btag == T_DBL)
+ if(btag == T_F64)
return db == db ? *(s64int*)a < (s64int)*(double*)b : 0;
if(btag == T_BIG)
return mpcmp(vtomp(*(s64int*)a, cmpmpint), *(mpint**)b) < 0;
}
if(btag == T_U64){
- if(atag == T_DBL)
+ if(atag == T_F64)
return da >= 0 ? *(u64int*)b > (u64int)*(double*)a : 0;
if(atag == T_BIG)
return mpcmp(*(mpint**)a, uvtomp(*(u64int*)b, cmpmpint)) < 0;
}
if(btag == T_S64){
- if(atag == T_DBL)
+ if(atag == T_F64)
return da == da ? *(s64int*)b > (s64int)*(double*)a : 0;
if(atag == T_BIG)
return mpcmp(*(mpint**)a, vtomp(*(s64int*)b, cmpmpint)) < 0;
@@ -207,13 +207,13 @@
s64int i64;
}u, v;
- if(atag == btag && (!equalnans || atag < T_FLT))
+ if(atag == btag && (!equalnans || atag < T_F32))
return cmp_same_eq(a, b, atag);
double da = conv_to_double(sl_nil, a, atag);
double db = conv_to_double(sl_nil, b, btag);
- if((int)atag >= T_FLT && (int)btag >= T_FLT){
+ if((int)atag >= T_F32 && (int)btag >= T_F32){
if(equalnans){
u.d = da; v.d = db;
return u.i64 == v.i64;
@@ -232,7 +232,7 @@
// we would already have concluded that it's bigger than b.
if(btag == T_S64)
return *(s64int*)b >= 0 && *(u64int*)a == *(u64int*)b;
- if(btag == T_DBL)
+ if(btag == T_F64)
return *(double*)b >= 0 && *(u64int*)a == (u64int)*(double*)b;
if(btag == T_BIG)
return mpcmp(uvtomp(*(u64int*)a, cmpmpint), *(mpint**)b) == 0;
@@ -240,7 +240,7 @@
if(atag == T_S64){
if(btag == T_U64)
return *(s64int*)a >= 0 && *(u64int*)a == *(u64int*)b;
- if(btag == T_DBL)
+ if(btag == T_F64)
return *(s64int*)a == (s64int)*(double*)b;
if(btag == T_BIG)
return mpcmp(vtomp(*(s64int*)a, cmpmpint), *(mpint**)b) == 0;
@@ -248,7 +248,7 @@
if(btag == T_U64){
if(atag == T_S64)
return *(s64int*)a >= 0 && *(u64int*)b == *(u64int*)a;
- if(atag == T_DBL)
+ if(atag == T_F64)
return *(double*)a >= 0 && *(u64int*)b == (u64int)*(double*)a;
if(atag == T_BIG)
return mpcmp(*(mpint**)a, uvtomp(*(u64int*)b, cmpmpint)) == 0;
@@ -256,7 +256,7 @@
if(btag == T_S64){
if(atag == T_U64)
return *(s64int*)b >= 0 && *(u64int*)b == *(u64int*)a;
- if(atag == T_DBL)
+ if(atag == T_F64)
return *(s64int*)b == (s64int)*(double*)a;
if(atag == T_BIG)
return mpcmp(*(mpint**)a, vtomp(*(s64int*)b, cmpmpint)) == 0;
--- a/src/print.c
+++ b/src/print.c
@@ -721,12 +721,12 @@
}
}else if(type == sl_runesym){
rune_print(f, *(Rune*)data);
- }else if(type == sl_floatsym || type == sl_doublesym){
+ }else if(type == sl_f32sym || type == sl_f64sym){
char buf[64];
double d;
int ndec;
- if(type == sl_floatsym){
- d = (double)*(float*)data;
+ if(type == sl_f32sym){
+ d = *(float*)data;
ndec = 8;
}else{
d = *(double*)data;
@@ -740,7 +740,7 @@
rep = signbit(d) ? "-nan.0" : "+nan.0";
else
rep = signbit(d) ? "-wtf.0" : "+wtf.0";
- if(type == sl_floatsym && !sl.print_princ && !weak){
+ if(type == sl_f32sym && !sl.print_princ && !weak){
n = ios_printf(f, "#%s(%s)", sym_name(type), rep);
if(n < 1)
goto err;
@@ -752,7 +752,7 @@
outsc(f, "-0.0");
else
outsc(f, "0.0");
- if(type == sl_floatsym && !sl.print_princ && !weak)
+ if(type == sl_f32sym && !sl.print_princ && !weak)
outc(f, 'f');
}else{
snprint_real(buf, sizeof(buf), d, 0, ndec, 3, 10);
@@ -760,7 +760,7 @@
outs(f, buf);
if(!hasdec)
outsc(f, ".0");
- if(type == sl_floatsym && !sl.print_princ && !weak)
+ if(type == sl_f32sym && !sl.print_princ && !weak)
outc(f, 'f');
}
}else if(type == sl_u64sym){
--- a/src/random.c
+++ b/src/random.c
@@ -35,14 +35,14 @@
return mk_u64(genrand64_int64(&ctx));
}
-BUILTIN("rand-double", rand_double)
+BUILTIN("rand-f64", rand_f64)
{
USED(args); USED(nargs);
- return mk_double(genrand64_real1(&ctx));
+ return mk_f64(genrand64_real1(&ctx));
}
-BUILTIN("rand-float", rand_float)
+BUILTIN("rand-f32", rand_f32)
{
USED(args); USED(nargs);
- return mk_float(genrand64_real1(&ctx));
+ return mk_f32(genrand64_real1(&ctx));
}
--- a/src/read.c
+++ b/src/read.c
@@ -42,7 +42,7 @@
d = strtod(tok, &end);
if(*end == '\0'){
if(pval)
- *pval = mk_double(d);
+ *pval = mk_f64(d);
return true;
}
// floats can end in f or f0
@@ -50,7 +50,7 @@
(end[1] == '\0' ||
(end[1] == '0' && end[2] == '\0'))){
if(pval)
- *pval = mk_float((float)d);
+ *pval = mk_f32((float)d);
return true;
}
}
@@ -58,12 +58,12 @@
if(*tok == '+' || *tok == '-'){
if(!strcasecmp(tok+1, "nan.0")){
if(pval)
- *pval = mk_double(*tok == '+' ? D_PNAN : D_NNAN);
+ *pval = mk_f64(*tok == '+' ? D_PNAN : D_NNAN);
return true;
}
if(!strcasecmp(tok+1, "inf.0")){
if(pval)
- *pval = mk_double(*tok == '+' ? D_PINF : D_NINF);
+ *pval = mk_f64(*tok == '+' ? D_PINF : D_NINF);
return true;
}
}
--- a/src/sl.c
+++ b/src/sl.c
@@ -28,7 +28,7 @@
sl_v sl_iosym, sl_rdsym, sl_wrsym, sl_apsym, sl_crsym, sl_truncsym;
sl_v sl_s8sym, sl_u8sym, sl_s16sym, sl_u16sym, sl_s32sym, sl_u32sym;
sl_v sl_s64sym, sl_u64sym, sl_p32sym, sl_p64sym, sl_ptrsym, sl_bignumsym;
-sl_v sl_utf8sym, sl_runesym, sl_floatsym, sl_doublesym;
+sl_v sl_utf8sym, sl_runesym, sl_f32sym, sl_f64sym;
sl_type *sl_bignumtype, *sl_builtintype;
sl_type *sl_s8type, *sl_u8type;
@@ -36,7 +36,7 @@
sl_type *sl_s32type, *sl_u32type;
sl_type *sl_s64type, *sl_u64type;
sl_type *sl_p32type, *sl_p64type;
-sl_type *sl_floattype, *sl_doubletype;
+sl_type *sl_f32type, *sl_f64type;
sl_type *sl_utf8type, *sl_runetype;
sl_type *sl_strtype;
--- a/src/sl.h
+++ b/src/sl.h
@@ -41,7 +41,7 @@
T_P64,
T_UNBOXED_NUM,
T_BIG = T_UNBOXED_NUM,
- T_FLT, T_DBL,
+ T_F32, T_F64,
}sl_numtype;
typedef uintptr sl_v;
@@ -100,7 +100,7 @@
#define ANYARGS -10000
#define NONNUMERIC (0xff)
-#define valid_numtype(v) ((v) <= T_DBL)
+#define valid_numtype(v) ((v) <= T_F64)
#define tag(x) ((x) & 7)
#define tagext(x) ((x) & 0xff)
#define ptr(x) ((void*)((uintptr)(x) & (~(uintptr)7)))
@@ -469,7 +469,7 @@
extern sl_v sl_iosym, sl_rdsym, sl_wrsym, sl_apsym, sl_crsym, sl_truncsym;
extern sl_v sl_s8sym, sl_u8sym, sl_s16sym, sl_u16sym, sl_s32sym, sl_u32sym;
extern sl_v sl_s64sym, sl_u64sym, sl_p32sym, sl_p64sym, sl_ptrsym, sl_bignumsym;
-extern sl_v sl_utf8sym, sl_runesym, sl_floatsym, sl_doublesym, sl_vecstructsym, sl_structsym;
+extern sl_v sl_utf8sym, sl_runesym, sl_f32sym, sl_f64sym, sl_vecstructsym, sl_structsym;
extern sl_type *sl_bignumtype, *sl_builtintype;
extern sl_type *sl_s8type, *sl_u8type;
@@ -477,7 +477,7 @@
extern sl_type *sl_s32type, *sl_u32type;
extern sl_type *sl_s64type, *sl_u64type;
extern sl_type *sl_p32type, *sl_p64type;
-extern sl_type *sl_floattype, *sl_doubletype;
+extern sl_type *sl_f32type, *sl_f64type;
extern sl_type *sl_utf8type, *sl_runetype;
extern sl_type *sl_strtype, *sl_runestrtype;
--- a/src/sl_arith_any.h
+++ b/src/sl_arith_any.h
@@ -35,8 +35,8 @@
type_error(nil, "num", arg);
}
switch(pt){
- case T_DBL: Faccum = ARITH_OP(Faccum, *(double*)a); inexact = true; continue;
- case T_FLT: Faccum = ARITH_OP(Faccum, *(float*)a); inexact = true; continue;
+ case T_F64: Faccum = ARITH_OP(Faccum, *(double*)a); inexact = true; continue;
+ case T_F32: Faccum = ARITH_OP(Faccum, *(float*)a); inexact = true; continue;
case T_S8: x = *(s8int*)a; break;
case T_U8: x = *(u8int*)a; break;
case T_S16: x = *(s16int*)a; break;
@@ -85,7 +85,7 @@
}
}
if(inexact)
- return mk_double(ARITH_OP(Faccum, Saccum));
+ return mk_f64(ARITH_OP(Faccum, Saccum));
if(fits_fixnum(Saccum))
return fixnum((sl_fx)Saccum);
u64 = ACCUM_DEFAULT;
@@ -118,8 +118,8 @@
goto typeerr;
}
switch(pt){
- case T_DBL: Faccum = ARITH_OP(Faccum, *(double*)a); inexact = true; continue;
- case T_FLT: Faccum = ARITH_OP(Faccum, *(float*)a); inexact = true; continue;
+ case T_F64: Faccum = ARITH_OP(Faccum, *(double*)a); inexact = true; continue;
+ case T_F32: Faccum = ARITH_OP(Faccum, *(float*)a); inexact = true; continue;
case T_S8: x = *(s8int*)a; break;
case T_U8: x = *(u8int*)a; break;
case T_S16: x = *(s16int*)a; break;
@@ -169,7 +169,7 @@
Saccum = mptov(Maccum);
mpfree(Maccum);
if(inexact)
- return mk_double(ARITH_OP(Faccum, Saccum));
+ return mk_f64(ARITH_OP(Faccum, Saccum));
assert(fits_fixnum(Saccum));
return fixnum((sl_fx)Saccum);
--- a/src/str.c
+++ b/src/str.c
@@ -372,7 +372,7 @@
return n;
}else if(iscvalue(n)){
sl_cv *data = ptr(n);
- if(cv_numtype(data) < T_FLT)
+ if(cv_numtype(data) < T_F32)
num = conv_to_u64(n, cv_data(data), cv_numtype(data));
else if(radix != 10)
bthrow(lerrorf(sl_errarg, "invalid radix with floating point"));
--- a/src/system.sl
+++ b/src/system.sl
@@ -437,7 +437,7 @@
(def (random n)
(if (int? n)
(mod (rand) n)
- (* (rand-double) n)))
+ (* (rand-f64) n)))
(def (abs x)
(if (< x 0)
--- a/src/vm.h
+++ b/src/vm.h
@@ -460,10 +460,10 @@
else{
sl_cv *p = ptr(v);
switch(cv_numtype(p)){
- case T_DBL:
+ case T_F64:
v = isnan(*(double*)cv_data(p)) ? sl_t : sl_nil;
break;
- case T_FLT:
+ case T_F32:
v = isnan(*(float*)cv_data(p)) ? sl_t : sl_nil;
break;
default:
--- a/test/number-boundaries.sl
+++ b/test/number-boundaries.sl
@@ -92,34 +92,34 @@
(int-conv bignum bignum)
-(defmacro (float-conv- type)
+(defmacro (f32-conv- type)
`(let ((l (low-border ,type))
(h (high-border ,type)))
(if (member ,type (list s64 u64))
- (assert (= 12345 (,type (double 12345))))
- (begin (assert (= l (,type (double l))))
- (assert (= h (,type (double h))))))
+ (assert (= 12345 (,type (f64 12345))))
+ (begin (assert (= l (,type (f64 l))))
+ (assert (= h (,type (f64 h))))))
(if (member ,type (list s32 u32 s64 u64))
- (assert (= 12345 (,type (float 12345))))
+ (assert (= 12345 (,type (f32 12345))))
(begin
- (assert (= l (,type (float l))))
- (assert (= h (,type (float h))))))))
+ (assert (= l (,type (f32 l))))
+ (assert (= h (,type (f32 h))))))))
-(defmacro (float-conv . types)
- `(void ,@(map (λ (type) `(float-conv- ,type)) types)))
+(defmacro (f32-conv . types)
+ `(void ,@(map (λ (type) `(f32-conv- ,type)) types)))
-(float-conv s8 u8 s16 u16 s32 u32 s64 u64)
+(f32-conv s8 u8 s16 u16 s32 u32 s64 u64)
-(assert (= (low-border s32) (bignum (double (low-border s32)))))
-(assert (= (high-border s32) (bignum (double (high-border s32)))))
-(assert (= (low-border s16) (bignum (float (low-border s16)))))
-(assert (= (high-border s16) (bignum (float (high-border s16)))))
+(assert (= (low-border s32) (bignum (f64 (low-border s32)))))
+(assert (= (high-border s32) (bignum (f64 (high-border s32)))))
+(assert (= (low-border s16) (bignum (f32 (low-border s16)))))
+(assert (= (high-border s16) (bignum (f32 (high-border s16)))))
-(assert (= (low-border s32) (double (s64 (low-border s32)))))
-(assert (= (high-border s32) (double (s64 (high-border s32)))))
+(assert (= (low-border s32) (f64 (s64 (low-border s32)))))
+(assert (= (high-border s32) (f64 (s64 (high-border s32)))))
-(assert (= 0.5f (double (float 0.5))))
-(assert (= 0.5 (float (double 0.5f))))
+(assert (= 0.5f (f64 (f32 0.5))))
+(assert (= 0.5 (f32 (f64 0.5f))))
; comparison of different types
@@ -126,8 +126,8 @@
(assert (< (u64 (1- (high-border s64))) (s64 (high-border s64))))
(assert (< (s64 (high-border s64)) (u64 (1+ (high-border s64)))))
(assert (< (s64 (high-border s64)) (u64 (1+ (high-border s64)))))
-(assert (< (u64 (1- (high-border s16))) (float (high-border s16))))
-(assert (< (float (high-border s16)) (u64 (1+ (high-border s16)))))
+(assert (< (u64 (1- (high-border s16))) (f32 (high-border s16))))
+(assert (< (f32 (high-border s16)) (u64 (1+ (high-border s16)))))
(assert (< (u64 (1- (high-border s64))) (bignum (high-border s64))))
(assert (> (u64 (1+ (high-border s64))) (bignum (high-border s64))))
(assert (< (s64 (1- (high-border s64))) (bignum (high-border s64))))
--- a/test/unittest.sl
+++ b/test/unittest.sl
@@ -8,10 +8,10 @@
(def (every-int n)
(list (fixnum n) (s8 n) (u8 n) (s16 n) (u16 n) (s32 n) (u32 n)
- (s64 n) (u64 n) (float n) (double n) (bignum n)))
+ (s64 n) (u64 n) (f32 n) (f64 n) (bignum n)))
(def (every-sint n)
- (list (fixnum n) (s8 n) (s16 n) (s32 n) (s64 n) (float n) (double n) (bignum n)))
+ (list (fixnum n) (s8 n) (s16 n) (s32 n) (s64 n) (f32 n) (f64 n) (bignum n)))
(def (each f l)
(if (atom? l) NIL
@@ -79,7 +79,7 @@
(assert (equal? (* 2 #s64(0x4000000000000000))
#u64(0x8000000000000000)))
-(assert (equal? (u64 (double -123)) #u64(0xffffffffffffff85)))
+(assert (equal? (u64 (f64 -123)) #u64(0xffffffffffffff85)))
(assert (equal? (str 'sym #utf8(65) #rune(945) "blah") "symA\u03B1blah"))
(assert (= (length (str #\x0)) 1))
@@ -124,30 +124,30 @@
; NaNs
(assert (nan? +nan.0))
(assert (nan? -nan.0))
-(assert (nan? (float +nan.0)))
-(assert (nan? (float -nan.0)))
+(assert (nan? (f32 +nan.0)))
+(assert (nan? (f32 -nan.0)))
(assert (equal? +nan.0 +nan.0))
(assert (equal? -nan.0 -nan.0))
-(assert (equal? (float +nan.0) (float +nan.0)))
-(assert (equal? (float -nan.0) (float -nan.0)))
+(assert (equal? (f32 +nan.0) (f32 +nan.0)))
+(assert (equal? (f32 -nan.0) (f32 -nan.0)))
(assert (not (= +nan.0 +nan.0)))
(assert (not (= +nan.0 -nan.0)))
(assert (not (= -nan.0 -nan.0)))
-(assert (not (= (float +nan.0) (float +nan.0))))
-(assert (not (= (float +nan.0) (float -nan.0))))
-(assert (not (= (float -nan.0) (float -nan.0))))
+(assert (not (= (f32 +nan.0) (f32 +nan.0))))
+(assert (not (= (f32 +nan.0) (f32 -nan.0))))
+(assert (not (= (f32 -nan.0) (f32 -nan.0))))
(assert (equal? (< +nan.0 3) (> 3 +nan.0)))
-(assert (equal? (< +nan.0 (double 3)) (> (double 3) +nan.0)))
-(assert (equal? (< +nan.0 3) (> (double 3) +nan.0)))
-(assert (equal? (< +nan.0 (double 3)) (> 3 +nan.0)))
-(assert (equal? (< +nan.0 3) (< +nan.0 (double 3))))
-(assert (equal? (> +nan.0 3) (> +nan.0 (double 3))))
-(assert (equal? (< 3 +nan.0) (> +nan.0 (double 3))))
-(assert (equal? (> 3 +nan.0) (> (double 3) +nan.0)))
+(assert (equal? (< +nan.0 (f64 3)) (> (f64 3) +nan.0)))
+(assert (equal? (< +nan.0 3) (> (f64 3) +nan.0)))
+(assert (equal? (< +nan.0 (f64 3)) (> 3 +nan.0)))
+(assert (equal? (< +nan.0 3) (< +nan.0 (f64 3))))
+(assert (equal? (> +nan.0 3) (> +nan.0 (f64 3))))
+(assert (equal? (< 3 +nan.0) (> +nan.0 (f64 3))))
+(assert (equal? (> 3 +nan.0) (> (f64 3) +nan.0)))
(assert (not (>= +nan.0 +nan.0)))
(assert (not (<= -nan.0 -nan.0)))
-(assert (not (>= (float +nan.0) (float +nan.0))))
-(assert (not (<= (float -nan.0) (float -nan.0))))
+(assert (not (>= (f32 +nan.0) (f32 +nan.0))))
+(assert (not (<= (f32 -nan.0) (f32 -nan.0))))
; comparing strings
(assert (< "a" "b"))
@@ -178,7 +178,7 @@
(assert (not (eqv? -0.0 0)))
(assert (not (eqv? -0.0 0.0)))
(assert (= 0.0 -0.0))
-; same but float
+; same but f32
(assert (not (equal? 0.0f 0)))
(assert (equal? 0.0f 0.0f))
(assert (not (equal? -0.0f 0.0f)))
@@ -866,17 +866,17 @@
(let ((ru32 (table))
(ru64 (table))
- (rdouble (table))
- (rfloat (table)))
+ (rf64 (table))
+ (rf32 (table)))
(dotimes (i 100)
(put! ru32 (rand-u32) 1)
(put! ru64 (rand-u64) 1)
- (put! rdouble (rand-double) 1)
- (put! rfloat (rand-float) 1))
+ (put! rf64 (rand-f64) 1)
+ (put! rf32 (rand-f32) 1))
(assert (< 50 (length ru32)))
(assert (< 50 (length ru64)))
- (assert (< 50 (length rdouble)))
- (assert (< 50 (length rfloat))))
+ (assert (< 50 (length rf64)))
+ (assert (< 50 (length rf32))))
;; auto gensym