Backup
This commit is contained in:
parent
f073d84eb4
commit
bf70aa7bab
5
Makefile
5
Makefile
|
|
@ -41,10 +41,9 @@ test: testfiles
|
||||||
cd .tmp && ./test-program
|
cd .tmp && ./test-program
|
||||||
|
|
||||||
test-docker: testfiles
|
test-docker: testfiles
|
||||||
cd .tmp && SNOW_PACKAGES="srfi.64 srfi.60 srfi.145 srfi.180 retropikzel.mouth" \
|
cd .tmp && SNOW_PACKAGES="srfi.39 srfi.64 srfi.60 srfi.145 srfi.180 retropikzel.mouth" \
|
||||||
APT_PACKAGES="libcurl4-openssl-dev" \
|
APT_PACKAGES="" \
|
||||||
COMPILE_R7RS=${SCHEME} \
|
COMPILE_R7RS=${SCHEME} \
|
||||||
CSC_OPIONS="-L -lcurl" \
|
|
||||||
test-r7rs test.${SFX} ${PKG}
|
test-r7rs test.${SFX} ${PKG}
|
||||||
|
|
||||||
retropikzel/wasm/plus.wasm: retropikzel/wasm/plus.c
|
retropikzel/wasm/plus.wasm: retropikzel/wasm/plus.c
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,22 @@
|
||||||
(define show-docstring?
|
(define return (make-parameter (lambda (x) x) (lambda (x) x)))
|
||||||
(make-parameter #f (lambda (x) x)))
|
|
||||||
|
|
||||||
(define docstring
|
(define doc-string
|
||||||
(make-parameter
|
(make-parameter
|
||||||
""
|
""
|
||||||
(lambda (str)
|
(lambda (x)
|
||||||
(if (show-docstring?)
|
(apply (return) (list x)))))
|
||||||
(error (string-append "docstring:" str))
|
|
||||||
""))))
|
|
||||||
|
|
||||||
;; TODO: stop at like 100 arguments, it means the procedure has no docstring
|
|
||||||
;; TODO: Change all arguments to procedures that throw errors
|
|
||||||
;; TODO: Use eval to run the procedure in empty environment so nothing happens if it does not have docstring?
|
|
||||||
(define (doc procedure)
|
(define (doc procedure)
|
||||||
(letrec*
|
(letrec*
|
||||||
((looper (lambda (args)
|
((looper
|
||||||
(call-with-current-continuation
|
(lambda (args cont)
|
||||||
(lambda (k)
|
(if (> (length args) 100)
|
||||||
(with-exception-handler
|
#f
|
||||||
(lambda (x)
|
(with-exception-handler
|
||||||
(let ((msg (error-object-message x)))
|
(lambda (x)
|
||||||
(if (string=? (string-copy msg 0 10) "docstring:")
|
(cont (looper (cons (lambda () (error "" '())) args) cont)))
|
||||||
(k (string-copy msg 10))
|
(lambda ()
|
||||||
(k (looper (cons #t args))))))
|
(return cont)
|
||||||
(lambda ()
|
(apply procedure args)))))))
|
||||||
(show-docstring? #t)
|
(call-with-current-continuation (lambda (cont) (looper '() cont)))))
|
||||||
(apply procedure args))))))))
|
|
||||||
(looper '())))
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@
|
||||||
(import (scheme base)
|
(import (scheme base)
|
||||||
(scheme write)
|
(scheme write)
|
||||||
(srfi 39))
|
(srfi 39))
|
||||||
(export docstring
|
(export doc-string
|
||||||
doc)
|
doc
|
||||||
|
)
|
||||||
(include "docstring.scm"))
|
(include "docstring.scm"))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,21 @@
|
||||||
;(test-begin "docstring")
|
;(test-begin "docstring")
|
||||||
|
|
||||||
|
|
||||||
(define (plus a b)
|
(define (plus a b)
|
||||||
(docstring "Adds a to b")
|
(doc-string "Add a to b")
|
||||||
(+ a b))
|
(+ a b))
|
||||||
|
|
||||||
(plus 1 2)
|
|
||||||
(write (doc plus))
|
(define (minus a b)
|
||||||
|
(- a b))
|
||||||
|
|
||||||
|
(write (plus 1 1))
|
||||||
|
(newline)
|
||||||
|
(display (doc plus))
|
||||||
(newline)
|
(newline)
|
||||||
|
|
||||||
|
(write (minus 1 1))
|
||||||
|
(newline)
|
||||||
|
(display (doc minus))
|
||||||
|
(newline)
|
||||||
|
|
||||||
;(test-end "docstring")
|
;(test-end "docstring")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue