eb328be4e513

Remove `symbolize`

It's `symb` from quickutils.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Tue, 23 Aug 2016 01:03:43 +0000
parents d39af38a14f8
children 22e0cd523d11
branches/tags (none)
files DOCUMENTATION.markdown losh.lisp make-docs.lisp make-quickutils.lisp package.lisp quickutils.lisp

Changes

--- a/DOCUMENTATION.markdown	Tue Aug 23 01:00:55 2016 +0000
+++ b/DOCUMENTATION.markdown	Tue Aug 23 01:03:43 2016 +0000
@@ -600,23 +600,31 @@
 
 ### `DEQUEUE` (function)
 
-    (DEQUEUE Q)
+    (DEQUEUE QUEUE)
+
+Dequeue an item from `queue` and return it.
 
 ### `ENQUEUE` (function)
 
-    (ENQUEUE ITEM Q)
+    (ENQUEUE ITEM QUEUE)
+
+Enqueue `item` in `queue`, returning the new size of the queue.
 
 ### `MAKE-QUEUE` (function)
 
     (MAKE-QUEUE)
 
+Allocate and return a fresh queue.
+
 ### `QUEUE` (struct)
 
 Slots: `CONTENTS`, `LAST`, `SIZE`
 
 ### `QUEUE-APPEND` (function)
 
-    (QUEUE-APPEND Q L)
+    (QUEUE-APPEND QUEUE LIST)
+
+Enqueue each element of `list` in `queue` and return the queue's final size.
 
 ### `QUEUE-CONTENTS` (function)
 
@@ -624,7 +632,9 @@
 
 ### `QUEUE-EMPTY-P` (function)
 
-    (QUEUE-EMPTY-P Q)
+    (QUEUE-EMPTY-P QUEUE)
+
+Return whether `queue` is empty.
 
 ### `QUEUE-SIZE` (function)
 
@@ -704,23 +714,6 @@
 
 Return a random boolean with `chance` probability of `t`.
 
-## Package `LOSH.SYMBOLS`
-
-Utilities related to symbols.
-
-### `SYMBOLIZE` (function)
-
-    (SYMBOLIZE &REST ARGS)
-
-Slap `args` together stringishly into a symbol and intern it.
-
-  Example:
-
-    (symbolize 'foo :bar "baz")
-    => 'foobarbaz
-
-  
-
 ## Package `LOSH.WEIGHTLISTS`
 
 A simple data structure for choosing random items with weighted probabilities.
--- a/losh.lisp	Tue Aug 23 01:00:55 2016 +0000
+++ b/losh.lisp	Tue Aug 23 01:03:43 2016 +0000
@@ -15,20 +15,6 @@
      ',name))
 
 
-;;;; Symbols
-(eval-when (:compile-toplevel :load-toplevel :execute)
-  (defun symbolize (&rest args)
-    "Slap `args` together stringishly into a symbol and intern it.
-
-  Example:
-
-    (symbolize 'foo :bar \"baz\")
-    => 'foobarbaz
-
-  "
-    (intern (format nil "~{~A~}" args))))
-
-
 ;;;; Math
 (defconstant tau (coerce (* pi 2) 'single-float)) ; fuck a pi
 
@@ -537,7 +523,7 @@
   "))
 
 (defmacro defun-fmda (type)
-  `(defun ,(symbolize 'fill-multidimensional-array- type) (array item)
+  `(defun ,(symb 'fill-multidimensional-array- type) (array item)
     ,(format nil *fmda-docstring* type)
     (fill-mda array item)))
 
@@ -1268,10 +1254,10 @@
 
   "
   (let* ((accessors (loop :for slot :in slots
-                          :collect (symbolize type '- slot)))
+                          :collect (symb type '- slot)))
          (symbol-args (loop :for slot :in slots
-                            :collect (symbolize slot '-symbol)))
-         (macro-name (symbolize 'with- type))
+                            :collect (symb slot '-symbol)))
+         (macro-name (symb 'with- type))
          (macro-arglist `((,type &optional
                            ,@(loop :for slot :in slots
                                    :for arg :in symbol-args
--- a/make-docs.lisp	Tue Aug 23 01:00:55 2016 +0000
+++ b/make-docs.lisp	Tue Aug 23 01:03:43 2016 +0000
@@ -16,7 +16,6 @@
         "LOSH.MUTATION"
         "LOSH.QUEUES"
         "LOSH.RANDOM"
-        "LOSH.SYMBOLS"
         "LOSH.WEIGHTLISTS"
 
         ))
--- a/make-quickutils.lisp	Tue Aug 23 01:00:55 2016 +0000
+++ b/make-quickutils.lisp	Tue Aug 23 01:03:43 2016 +0000
@@ -5,6 +5,7 @@
   :utilities '(:curry
                :rcurry
                :emptyp
+               :symb
                :ensure-list
                :with-gensyms
                :once-only)
--- a/package.lisp	Tue Aug 23 01:00:55 2016 +0000
+++ b/package.lisp	Tue Aug 23 01:03:43 2016 +0000
@@ -28,11 +28,6 @@
   "))
 
 
-(defsubpackage #:losh.symbols
-  (:documentation "Utilities related to symbols.")
-  (:export
-    #:symbolize))
-
 (defsubpackage #:losh.math
   (:documentation "Utilities related to math and numbers.")
   (:export
--- a/quickutils.lisp	Tue Aug 23 01:00:55 2016 +0000
+++ b/quickutils.lisp	Tue Aug 23 01:03:43 2016 +0000
@@ -2,7 +2,7 @@
 ;;;; See http://quickutil.org for details.
 
 ;;;; To regenerate:
-;;;; (qtlc:save-utils-as "quickutils.lisp" :utilities '(:CURRY :RCURRY :EMPTYP :ENSURE-LIST :WITH-GENSYMS :ONCE-ONLY) :ensure-package T :package "LOSH.QUICKUTILS")
+;;;; (qtlc:save-utils-as "quickutils.lisp" :utilities '(:CURRY :RCURRY :EMPTYP :SYMB :ENSURE-LIST :WITH-GENSYMS :ONCE-ONLY) :ensure-package T :package "LOSH.QUICKUTILS")
 
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (unless (find-package "LOSH.QUICKUTILS")
@@ -15,8 +15,9 @@
 (when (boundp '*utilities*)
   (setf *utilities* (union *utilities* '(:MAKE-GENSYM-LIST :ENSURE-FUNCTION
                                          :CURRY :RCURRY :NON-ZERO-P :EMPTYP
-                                         :ENSURE-LIST :STRING-DESIGNATOR
-                                         :WITH-GENSYMS :ONCE-ONLY))))
+                                         :MKSTR :SYMB :ENSURE-LIST
+                                         :STRING-DESIGNATOR :WITH-GENSYMS
+                                         :ONCE-ONLY))))
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (defun make-gensym-list (length &optional (x "G"))
     "Returns a list of `length` gensyms, each generated as if with a call to `make-gensym`,
@@ -85,6 +86,23 @@
     (:method ((x hash-table)) (zerop (hash-table-count x))))
   
 
+  (defun mkstr (&rest args)
+    "Receives any number of objects (string, symbol, keyword, char, number), extracts all printed representations, and concatenates them all into one string.
+
+Extracted from _On Lisp_, chapter 4."
+    (with-output-to-string (s)
+      (dolist (a args) (princ a s))))
+  
+
+  (defun symb (&rest args)
+    "Receives any number of objects, concatenates all into one string with `#'mkstr` and converts them to symbol.
+
+Extracted from _On Lisp_, chapter 4.
+
+See also: `symbolicate`"
+    (values (intern (apply #'mkstr args))))
+  
+
   (defun ensure-list (list)
     "If `list` is a list, it is returned. Otherwise returns the list designated by `list`."
     (if (listp list)
@@ -175,7 +193,7 @@
                ,@forms)))))
   
 (eval-when (:compile-toplevel :load-toplevel :execute)
-  (export '(curry rcurry emptyp ensure-list with-gensyms with-unique-names
+  (export '(curry rcurry emptyp symb ensure-list with-gensyms with-unique-names
             once-only)))
 
 ;;;; END OF quickutils.lisp ;;;;