diff --git a/forge/sf.lisp b/forge/sf.lisp index 8186fe8..a1d9a51 100644 --- a/forge/sf.lisp +++ b/forge/sf.lisp @@ -17,7 +17,21 @@ ;;;; core definitions -(defclass word () ()) +(defgeneric exec-item (it) + (:method ((it t)) + (pushd it)) + (:method ((it symbol)) + (funcall (func (symbol-value it))))) + +(defgeneric comp-item (it)) + +(defgeneric call-item (it)) + +(defclass word () + ((func :reader func :initarg :func))) + +(defmethod call-item ((it word)) + (funcall (func it))) (defclass comp-word (word) ()) @@ -28,14 +42,9 @@ (defun exec-input () (iter:process *input* #'exec-item)) -(defun exec-item (item) - (typecase item - (function (funcall item)) - (symbol (funcall (symbol-value item))) - (t (pushd item)))) - (defun reg (sym fn) - (setf (symbol-value sym) fn)) + (setf (symbol-value sym) (make-instance 'word :func fn))) + ;(setf (symbol-value sym) fn)) (defun reg2 (sym fn) (reg sym #'(lambda () (pushd (funcall fn (popd) (popd))))))