|
|
@ -21,8 +21,11 @@
|
|
|
|
(export ',val)
|
|
|
|
(export ',val)
|
|
|
|
nil))
|
|
|
|
nil))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;(defmacro export* (&rest syms)
|
|
|
|
|
|
|
|
; `(mapc #'export '(,@syms)))
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro export* (&rest syms)
|
|
|
|
(defmacro export* (&rest syms)
|
|
|
|
`(mapc #'export '(,@syms)))
|
|
|
|
(cons 'progn (mapcan #'(lambda (x) `((export ',x))) syms)))
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro eval-all (syms)
|
|
|
|
(defmacro eval-all (syms)
|
|
|
|
`(mapcar #'eval '(,@syms)))
|
|
|
|
`(mapcar #'eval '(,@syms)))
|
|
|
@ -70,7 +73,7 @@
|
|
|
|
(mapc #'(lambda (stmt) (write stmt :stream output-lisp :pretty nil)) this)
|
|
|
|
(mapc #'(lambda (stmt) (write stmt :stream output-lisp :pretty nil)) this)
|
|
|
|
(write sysdef :stream output-asd :case :downcase )))))
|
|
|
|
(write sysdef :stream output-asd :case :downcase )))))
|
|
|
|
|
|
|
|
|
|
|
|
(defun utils->create-for (utils for &key (name 'flan-utils) (package nil) ) ;;; TODO: Make this work /for structs/ at all
|
|
|
|
(defun utils->create-for (utils for &key (name 'flan-utils) ) ;;; TODO: Make this work /for structs/ at all
|
|
|
|
"Export `utils' functions used in file into own file"
|
|
|
|
"Export `utils' functions used in file into own file"
|
|
|
|
(let ((this (cadddr (read-from-string (file-get-contents utils))))
|
|
|
|
(let ((this (cadddr (read-from-string (file-get-contents utils))))
|
|
|
|
(for (read-from-string (file-get-contents for))))
|
|
|
|
(for (read-from-string (file-get-contents for))))
|
|
|
@ -212,10 +215,10 @@
|
|
|
|
strs)
|
|
|
|
strs)
|
|
|
|
0 -2))))
|
|
|
|
0 -2))))
|
|
|
|
|
|
|
|
|
|
|
|
(defun export-struct (struct &optional (symbols nil))
|
|
|
|
(defun export-struct (struct &optional (symbols nil)) ;;XXX: Export make-*
|
|
|
|
(mapc #'export (symbol-match (strcat "^" (write-to-string struct) "-?") symbols)))
|
|
|
|
(mapc #'export (symbol-match (strcat "^" (write-to-string struct) "-?") symbols)))
|
|
|
|
|
|
|
|
|
|
|
|
(defun -export*-struct (structs &optional (symbols nil))
|
|
|
|
(defun -export*-struct (structs &optional (symbols nil)) ;;XXX: Export make-*
|
|
|
|
(mapc #'export (symbol-match
|
|
|
|
(mapc #'export (symbol-match
|
|
|
|
(strcat
|
|
|
|
(strcat
|
|
|
|
"^("
|
|
|
|
"^("
|
|
|
@ -235,6 +238,9 @@
|
|
|
|
(flatten-top-level lists))
|
|
|
|
(flatten-top-level lists))
|
|
|
|
ret))
|
|
|
|
ret))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun cyclic (list)
|
|
|
|
|
|
|
|
(cdr (rplacd (last list) list)))
|
|
|
|
|
|
|
|
|
|
|
|
(defun map1 (lam &rest lists)
|
|
|
|
(defun map1 (lam &rest lists)
|
|
|
|
"Map and return first"
|
|
|
|
"Map and return first"
|
|
|
|
(let ((ret '())
|
|
|
|
(let ((ret '())
|
|
|
@ -266,6 +272,8 @@
|
|
|
|
(apply #'values
|
|
|
|
(apply #'values
|
|
|
|
(mapcar lam (flatten-top-level args))))
|
|
|
|
(mapcar lam (flatten-top-level args))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro lexical-boundp (lex)
|
|
|
|
|
|
|
|
`(when (ignore-errors ,lex) t))
|
|
|
|
;; --- progressive evals
|
|
|
|
;; --- progressive evals
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro progen (&rest things)
|
|
|
|
(defmacro progen (&rest things)
|
|
|
@ -283,8 +291,55 @@
|
|
|
|
(defmacro progel (&rest things)
|
|
|
|
(defmacro progel (&rest things)
|
|
|
|
`(mapcar #'eval '(,@things)))
|
|
|
|
`(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))
|
|
|
|
|
|
|
|
,@things
|
|
|
|
|
|
|
|
--yield-vars))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro yield (value)
|
|
|
|
|
|
|
|
`(when (boundp '--yield-vars)
|
|
|
|
|
|
|
|
(push ,value --yield-vars)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defparameter *yield-global-vars* '())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro yield-return-global (name &rest things)
|
|
|
|
|
|
|
|
"Like yield-return but stores values by key in alist and is accessable outside of current lexenv"
|
|
|
|
|
|
|
|
`(car (yield-return
|
|
|
|
|
|
|
|
(push (cons ,name '()) *yield-global-vars*)
|
|
|
|
|
|
|
|
,@things
|
|
|
|
|
|
|
|
(yield (cdr (assoc ,name *yield-global-vars*)))
|
|
|
|
|
|
|
|
(setf *yield-global-vars* (remove ,name *yield-global-vars* :key #'car :count 1)))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro yield-global (name value)
|
|
|
|
|
|
|
|
`(when (assoc ,name *yield-global-vars*)
|
|
|
|
|
|
|
|
(push ,value (cdr (assoc ,name *yield-global-vars*)))))
|
|
|
|
|
|
|
|
|
|
|
|
;; ---
|
|
|
|
;; ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro push-unique (thing things &key (key nil) (test #'eql))
|
|
|
|
|
|
|
|
`(let ((lex-thing ,thing))
|
|
|
|
|
|
|
|
(if (member lex-thing ,things :key ,key :test ,test)
|
|
|
|
|
|
|
|
(values ,things nil)
|
|
|
|
|
|
|
|
(values (push lex-thing ,things) t))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro import* (&rest args)
|
|
|
|
|
|
|
|
(cons 'progn (mapcan #'(lambda (x) `((import ',x))) args)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro shadowing-import* (&rest args)
|
|
|
|
|
|
|
|
(cons 'progn (mapcan #'(lambda (x) `((shadowing-import ',x))) args)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro import*! (&rest args)
|
|
|
|
|
|
|
|
`(mapc #'import (progel ,args)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro shadowing-import*! (&rest args)
|
|
|
|
|
|
|
|
`(mapc #'shadowing-import (progel ,args)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defmacro import*-from (package &rest args)
|
|
|
|
|
|
|
|
(let ((ret (mapcar #'(lambda (x) (read-from-string (strcat (subseq (write-to-string package) 1) ":" (write-to-string x)))) args)))
|
|
|
|
|
|
|
|
`(shadowing-import* @,ret)))
|
|
|
|
|
|
|
|
|
|
|
|
(defun restrain-index (i max)
|
|
|
|
(defun restrain-index (i max)
|
|
|
|
(if nil
|
|
|
|
(if nil
|
|
|
|
(if (>= i max) (1- max)
|
|
|
|
(if (>= i max) (1- max)
|
|
|
|