# HG changeset patch # User Steve Losh # Date 1486642633 0 # Node ID 95495223e6c1be5a1bd6ae943a4607f462dc8b23 # Parent c9ecd6ef59b9a9ed12bc6849397a69903df25604 Rename `ensure-aref`, formatting diff -r c9ecd6ef59b9 -r 95495223e6c1 package.lisp --- a/package.lisp Sat Nov 05 01:39:28 2016 +0000 +++ b/package.lisp Thu Feb 09 12:17:13 2017 +0000 @@ -9,7 +9,7 @@ #:recur #:megabytes #:ecase/tree - #:aref-or-init + #:ensure-aref #:define-lookup #:queue #:make-queue @@ -64,6 +64,7 @@ #:make-database #:reset-standard-database + #:with-database #:with-fresh-database #:invoke-rule diff -r c9ecd6ef59b9 -r 95495223e6c1 src/utils.lisp --- a/src/utils.lisp Sat Nov 05 01:39:28 2016 +0000 +++ b/src/utils.lisp Thu Feb 09 12:17:13 2017 +0000 @@ -1,4 +1,4 @@ -(in-package #:temperance.utils) +(in-package :temperance.utils) (defmacro push-if-new (thing place &environment env @@ -54,7 +54,7 @@ ,@body)) (recur ,@(mapcar #'extract-val bindings))))) -(defmacro aref-or-init (array index default-form) +(defmacro ensure-aref (array index default-form) "Get `index` in `array`, initializing if necessary. If `index` is non-nil in `array`: return its value without evaluating @@ -64,11 +64,9 @@ returning it. " - ;; TODO: think up a less shitty name for this (once-only (index array) `(or (aref ,array ,index) - (setf (aref ,array ,index) ,default-form)))) - + (setf (aref ,array ,index) ,default-form)))) (defun megabytes (n) "Return the number of 64-bit words in `n` megabytes." diff -r c9ecd6ef59b9 -r 95495223e6c1 src/wam.lisp --- a/src/wam.lisp Sat Nov 05 01:39:28 2016 +0000 +++ b/src/wam.lisp Thu Feb 09 12:17:13 2017 +0000 @@ -634,8 +634,8 @@ (values (gethash functor atable))))) (defun (setf wam-code-label) (new-value wam functor arity) - (setf (gethash functor (aref-or-init (wam-code-labels wam) arity - (make-hash-table :test 'eq))) + (setf (gethash functor (ensure-aref (wam-code-labels wam) arity + (make-hash-table :test 'eq))) new-value)) (defun wam-code-label-remove! (wam functor arity)