-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.lisp
35 lines (29 loc) · 1.09 KB
/
debug.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(in-package :celwk)
(defmacro with-time (codes)
`(progn
(format *trace-output* "~2&~a" ',codes)
(time ,codes)))
(defmacro io (fmt &rest args)
(setf fmt (concat fmt "~&"))
`(progn
(output ,fmt ,@args)
(input ,fmt ,@args)))
;; @defun => defun with both &rest & &key [functional.lisp]
;; ($output `Hello, Coder ~a` `Can` :width 70)
(@defun $output (control-string &rest format-args &key (width 80))
(princ (input "~2&~a~%~a~&~2:*~a~%"
(string-repeat "-" width)
(apply #'format nil control-string format-args))))
(@defun $error (control-string &rest format-args &key (width 100))
(princ (input "~2&~a~%~a~&~2:*~a~%"
(string-repeat "*" width)
(apply #'format nil control-string format-args))
*error-output*))
(defmacro output+ (&rest vars)
(let ((format (make-string-output-stream)))
(dolist (_ vars)
(write-string "~a: ~a~2%" format))
`($output ,(get-output-stream-string format)
,@(mapcan λ`(',_ ,_) vars))))
;; (defun manifest (&key (port 6666))
;; (manifest:start :port port))