Common Lisp Package: COM.GOOGLE.BASE

Basic code used by all applications. The code in BASE should be universally useful, since most packages will import BASE symbols by including (:USE #:COM.GOOGLE.BASE) in their DEFPACKAGE form.

README:

FUNCTION

Public

MAKE-OCTET-VECTOR (OCTET-COUNT &KEY INITIAL-CONTENTS)

Create an OCTET-VECTOR containing OCTET-COUNT octets. If INITIAL-CONTENTS is not supplied, each element of the vector is initialized to zero. Otherwise, the vector is initialized to the contents of list INITIAL-CONTENTS.

MISSING-ARGUMENT

Signal an error indicating that an &OPTIONAL or &KEY argument is missing. Use (MISSING-ARGUMENT) as the default value of required &KEY function arguments and as the initform in DEFCLASS and DEFSTRUCT slot definition forms when the slot's initform must always be supplied to MAKE-INSTANCE.

PREFIXP (PREFIX SEQUENCE &KEY (TEST #'EQL))

Does PREFIX match a prefix of SEQUENCE?

STRING-TO-UTF8-OCTETS (STRING &KEY (START 0) (END (LENGTH STRING)))

Convert STRING into an OCTET-VECTOR by UTF-8 encoding each character.

SUFFIXP (SUFFIX SEQUENCE &KEY (TEST #'EQL))

Does SUFFIX match a suffix of SEQUENCE?

UTF8-OCTETS-TO-STRING (OCTETS &KEY (START 0) (END (LENGTH OCTETS)))

Convert OCTETS, a vector of UTF-8 encoded octets, into a string.

MACRO

Public

DEFCONST (NAME VALUE &OPTIONAL (DOCUMENTATION NIL DOCUMENTATION-PRESENT-P))

Identical to CL:DEFCONSTANT except that the global constant variable NAME is bound to VALUE at compile time so it can be used in #. reader forms. Additionally, if the DEFCONST form is evaluated a second time, the constant is not rebound if the new value is EQUALP to the old. CL:DEFCONSTANT requires that the two values be EQL to avoid undefined behavior.

DEFINE-PRINT-OBJECT (CLASS-NAME ACCESSOR-INFO)

Generates a CL:PRINT-OBJECT generic function for class CLASS-NAME using ACCESSOR-INFO, a list containing elements of the form (accessor initarg [format-string]). If a format-string is not provided for a slot, then the generated PRINT-OBJECT function outputs nothing for that slot when *PRINT-READABLY* is false. Given a POINT class with slots X, Y, and HIDDEN. The following DEFINE-PRINT-OBJECT form: (define-print-object point ((x :x "x is ~D") (y :y "y is ~D") (hidden :hidden))) expands to a PRINT-OBJECT function similar to: (defmethod print-object ((point point) stream) (if *print-readably* (progn (write-string "#." stream) (write `(make-instance 'point :x ,(x point) :y ,(y point) :hidden ,(hidden point)) :stream stream)) (print-unreadable-object (point stream :type t :identity t) (format stream "x is ~D y is ~D" (x point) (y point)))))

VARIABLE

Public

*OPTIMIZE-DEFAULT*

Compiler optimization settings that emphasize debugging over speed. Most code should use these settings.

*OPTIMIZE-FAST-UNSAFE*

Compiler optimization settings that emphasize speed at the expense of debugging and run-time safety. Only low-level performance sensitive code that has been extensively tested should use these settings.

CONSTANT

Public

+MAXIMUM-VECTOR-INDEX+

Largest valid vector index.