shithub: sl

ref: f141f26d2af52b4f6ac6c81f2824367c63b9e112
dir: /src/docs_extra.lsp/

View raw version
(defmacro (doc-for term (doc nil))
  "Define documentation for a top level term.
   If the optional doc argument is missing and the term is a function
   signture, adds it to the documentation."
  (let* ((call (cons? term))
         (sym  (or (and call (car term))
                   term))
         (callvars (and call (cdr term))))
    (if call
        `(void (sym-set-doc ',sym ,doc ',callvars))
        `(void (sym-set-doc ',sym ,doc)))))

(doc-for (= a . rest)
  "Return T if the arguments are equal.")

(doc-for (nan? x)
  "Return T if the argument is NaN, regardless of the sign.")

(doc-for (vm-stats)
  "Print various VM-related information, such as the number of GC calls so far, heap and stack size, etc.")

(doc-for (lz-pack data (level 0))
  "Return data compressed using Lempel-Ziv.
   The data must be an array, returned value will have the same type.
   The optional level is between 0 and 10.  With level 0 a simple LZSS
   using hashing will be performed.  Levels between 1 and 9 offer a
   trade-off between time/space and ratio.  Level 10 is optimal but very
   slow.")

(doc-for (lz-unpack data :to destination))
(doc-for (lz-unpack data :size decompressed-bytes)
  "Return decompressed data previously compressed using lz-pack.
   Either destination for the decompressed data or the expected size of
   the decompressed data must be specified.  In the latter case a new
   array is allocated.")

(doc-for (rand)
  "Return a random non-negative fixnum on its maximum range.")

(doc-for (rand-u64)
  "Return a random integer on [0, 2⁶⁴-1] interval.")

(doc-for (rand-u32)
  "Return a random integer on [0, 2³²-1] interval.")

(doc-for (rand-double)
  "Return a random double on [0.0, 1.0] interval.")

(doc-for (rand-float)
  "Return a random float on [0.0, 1.0] interval.")

(doc-for NIL
  "An empty list. Also used as the opposite of T.
      (not NIL)         → T
      (if NIL 'yes 'no) → 'no
      (car NIL)         → NIL
      (cdr NIL)         → NIL")

(doc-for T
  "A boolean \"true\".
      (not T)         → NIL
      (if T 'yes 'no) → 'yes")