shithub: femtolisp

ref: 5e28ffc053ddf65898820550a7c7f1712bb10543
dir: /docs_extra.lsp/

View raw version
(define-macro (doc-for term doc)
  (let* ((sym     (or (and (cons? term) (car term)) term))
         (val     (top-level-value sym))
         (funvars (and (cons? term) (cdr term))))
    (if (not funvars)
        (when (function? val)
          (error "docs: " sym ": no funvars specified"))
        (unless (function? val)
          (error "docs: " sym ": funvars set but isn't a function")))
    (symbol-set-doc sym doc funvars)))

(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 decompressed-bytes)
  "Return decompressed data previously compressed using lz-pack.
The decompressed-bytes parameter is the expected size of the
decompressed data.")

(del! *syntax-environment* 'doc-for)