shithub: femtolisp

Download patch

ref: 489a3e1552b528eb06fc393bd8f5a66702ca82c2
parent: 24e4a3e1ba4ac78b1b9400aae963c69d21ca2b86
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon Dec 23 20:58:50 EST 2024

docs_extra.lsp: mainly for C builtins

Fixes: https://todo.sr.ht/~ft/femtolisp/28

--- /dev/null
+++ b/docs_extra.lsp
@@ -1,0 +1,16 @@
+(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.")
+
+(del! *syntax-environment* 'doc-for)
--- a/flisp.boot
+++ b/flisp.boot
@@ -14,7 +14,7 @@
 	      #fn("6000n201l:" #()) #fn("6000n201m:" #()) 0 #fn("8000z0700}2:" #(vector))
 	      #fn("8000z0700}2:" #(aset!)) 0 0 0 0 0 0 0 0 0 0 0 #fn("9000n3012082>1|:" #(#fn("6000n1A061:" #())))
 	      0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #fn("8000z0700}2:" #(aref)) 0 0)
-	    *properties* #table(*funvars* #table(void? (x)  length= (lst n)  help (term)  void rest)  *doc* #table(void? "Return #t if x is #<void> and #f otherwise."  length= "Bounded length test.\nUse this instead of (= (length lst) n), since it avoids unnecessary\nwork and always terminates."  help "Display documentation for the specified term, if available."  void "Return the constant #<void> while ignoring any arguments.\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."  *properties* "All properties of symbols recorded with putprop are recorded in this table."))
+	    *properties* #table(*funvars* #table(void? (x)  length= (lst n)  help (term)  void rest  vm-stats nil)  *doc* #table(void? "Return #t if x is #<void> and #f otherwise."  length= "Bounded length test.\nUse this instead of (= (length lst) n), since it avoids unnecessary\nwork and always terminates."  help "Display documentation for the specified term, if available."  void "Return the constant #<void> while ignoring any arguments.\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."  vm-stats "Print various VM-related information, such as the number of GC calls\nso far, heap and stack size, etc."  *properties* "All properties of symbols recorded with putprop are recorded in this table."))
 	    *runestring-type* (array rune) *string-type* (array byte)
 	    *syntax-environment* #table(unwind-protect #fn("A000n220502050218722q1e3e2e1232402286e12587e12686e2e3e3e387e1e3e3:" #(#fn(gensym)
   let λ prog1 trycatch begin raise))  help #fn("<000n170021527002252853\\0738551474504863B07450475086P51@30O47450@B0732627051524745047860:" #(getprop
--- a/system.lsp
+++ b/system.lsp
@@ -1098,3 +1098,5 @@
              (__rcscript)
              (repl)))
   (exit 0))
+
+#.(load "docs_extra.lsp")