;;; -*- Mode: LISP; Package: KR; Base: 10; Syntax: Common-Lisp -*- ;;*******************************************************************;; ;; The Garnet User Interface Development Environment. ;; ;;*******************************************************************;; ;; This code was written as part of the Garnet project at ;; ;; Carnegie Mellon University, and has been placed in the public ;; ;; domain. ;; ;;*******************************************************************;; ;;; $Id:: $ ;;; (in-package :kr) (defvar *setup-dependencies* T "If T (the default), dependencies are set up whenever GV and GVL are evaluated inside formulas. If nil, no dependencies are set up.") ;;; Fixed-path code. ;; (defun fixed-path-accessor (schema slots path-number) (let* ((current (a-formula-path *current-formula*)) (length (length current))) (or (and (< path-number length) (elt current path-number)) (progn (dolist (slot slots) (setf schema (g-value schema slot)) (when (listp schema) ;; This handles relation slots, which are ALWAYS stored as ;; a list. (setf schema (first schema)))) (unless (> length path-number) ;; create more storage (setf current (setf (a-formula-path *current-formula*) (append current (make-list (- path-number length -1)))))) (setf (elt current path-number) schema) schema)))) (defmacro kr-path (path-number &rest slots) `(fixed-path-accessor *schema-self* ',slots ,path-number)) ;;; FORMULAS ;; ;; Reuses one of the destroyed formulas, or allocates one if none exist. ;; FMG Note: *reuse-formulas* is set to nil to defeat this. (defun make-new-formula () (let ((f (formula-pop))) (if f ;; Reuse a formula (progn (setf (a-formula-depends-on f) nil) (setf (a-formula-cached-value f) nil) (setf (a-formula-path f) nil) (setf (a-formula-is-a f) nil) (setf (a-formula-function f) nil) (setf (a-formula-lambda f) nil) (setf (a-formula-is-a-inv f) nil)) ;; No formulas to reuse (setf f (make-a-formula)) ) (set-formula-number f 0) f)) (defun formula-fn (form &optional (initial-value nil) meta) "Creates an interpreted formula. The