--- a/src/base.lisp Wed Nov 14 18:31:39 2018 -0500
+++ b/src/base.lisp Wed Nov 14 18:42:31 2018 -0500
@@ -74,6 +74,21 @@
(defun pbpaste ()
(values (sh '("pbpaste") :output t)))
+(defgeneric ref% (object key))
+
+(defmethod ref% ((object hash-table) key)
+ (gethash key object))
+
+(defmethod ref% ((object vector) key)
+ (aref object key))
+
+(defun ref (object &rest keys)
+ (recursively ((object object)
+ (keys keys))
+ (if (null keys)
+ object
+ (recur (ref% object (first keys)) (rest keys)))))
+
;;;; Help ---------------------------------------------------------------------
(defun first-letter (command)
@@ -257,6 +272,11 @@
(throw :do-not-add-undo-state nil))
+;;;; Commands/Objects ---------------------------------------------------------
+(define-command ref (object key)
+ (push! (ref object key)))
+
+
;;;; Commands/System ----------------------------------------------------------
(define-command doc (symbol)
"Print the documentation for the symbol at the top of the stack."