Improved stuff

master
Ringo Wantanabe 6 years ago
parent 086319dff0
commit 20dcd429ea
No known key found for this signature in database
GPG Key ID: DDDD9B6759158726

@ -298,15 +298,18 @@
`(mapcar #'eval '(,@things)))
(defmacro yield-return (&rest things)
"Create yield block, returns list of push()ed outputs of yield() (so, last is first etc)"
`(let ((--yield-vars '()))
(declare (special --yield-vars))
"Create yield block, returns last of push()ed outputs of yield() (so, last is first etc)"
`(let ((--yield-vars '())
(--yield-var nil))
(declare (special --yield-vars
--yield-var))
,@things
--yield-vars))
(apply #'values --yield-var)))
(defmacro yield (value)
`(when (boundp '--yield-vars)
(push ,value --yield-vars)))
(setf --yield-var (multiple-value-list ,value))
(push (car --yield-var) --yield-vars)))
(defparameter *yield-global-vars* '())
@ -396,6 +399,15 @@
(wait (async-info-thread handle))
(bt:join-thread handle)))
(defun async-kill (handle)
(if (async-info-p handle)
(async-kill (async-info-thread handle))
(bt:destroy-thread handle)))
(defun async-alive (handle)
(if (async-info-p handle)
(async-alive (async-info-thread handle))
(bt:thread-alive-p handle)))
(defun val (v) v)
@ -452,16 +464,22 @@
(cons 'async (list thing))
thing)))
(defun lambda-reader (stream char)
(declare (ignore char))
`(lambda () ,(read stream t nil t)))
(defmacro enable-all-readers ()
"Turn on reader macros"
'(eval-when (:compile-toplevel :load-toplevel :execute)
(push *readtable* *old-readtables*)
(setq *readtable* (copy-readtable))
(set-macro-character #\¬ 'bang-reader) ;"Negates next statement"
(set-macro-character #\[ 'export-reader) ;"Exports all in brackets []"
(set-macro-character #\] 'read-delimiter)
(set-macro-character #\$ 'async-reader) ;"Run statement in seperate thread"
(set-macro-character #\~ 'top-level-reader))) ;"Run at compile,load and execute"
(set-macro-character #\¬ 'bang-reader) ;"Negates next statement"
(set-macro-character #\£ 'lambda-reader) ;"Wrap statement in lambda"
(set-macro-character #\€ 'top-level-reader))) ;"Run at compile,load and execute"
(defmacro disable-all-readers()
"Turn off reader macros"

Loading…
Cancel
Save