95495223e6c1

Rename `ensure-aref`, formatting
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Thu, 09 Feb 2017 12:17:13 +0000
parents c9ecd6ef59b9
children fd638982ad83
branches/tags (none)
files package.lisp src/utils.lisp src/wam.lisp

Changes

--- 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
--- 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."
--- 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)