metatilities-base

API Reference

metatilities-base

These are metabang.com's Common Lisp basic utilities.

METABANG.UTILITIES

  • Generic-Function INSPECT-THING* (interface thing &rest args)
  • Generic-Function MAKE-PROGRESS-BAR (interface min max title &key)
  • Generic-Function PROGRESS-BAR-VALUE (interface bar)
  • Generic-Function (setf PROGRESS-BAR-VALUE) (value interface bar)
  • Generic-Function CLOSE-PROGRESS-BAR (interface bar)
  • Generic-Function MAKE-UI-POINT* (interface x y)
  • Function FIXNUMP (arg)
    Same as (typep arg 'fixnum). A lot of Explorer code was written using this, and it's easier to implement it than to change them all.
  • Function NEQ (left right)
  • Function FORM-SYMBOL-IN-PACKAGE (package &rest names)
    Finds or interns a symbol in package whose name is formed by concatenating the pretty printed representation of the names together.
  • Function FORM-SYMBOL (&rest names)
    Finds or interns a symbol in the current package whose name is formed by concatenating the pretty printed representation of the names together.
  • Function FORM-KEYWORD (&rest names)
    Finds or interns a symbol in the keyword package whose name is formed by concatenating the pretty printed representation of the names together.
  • Function FORM-UNINTERNED-SYMBOL (&rest names)
    Creates and returns an uninterned symbol whose name is formed by concatenating the pretty printed representation of the names together.
  • Function CURRENT-LOAD-FILE
    Returns (if possible) the value of the file currently being loaded or from which code is currently being evaluated.
  • Macro WITH-UNIQUE-NAMES ((&rest vars) &body body)
    Binds the symbols in VARS to gensyms. cf with-gensyms.
  • Function ENSURE-LIST (x)
    If `x` is a list then ensure-list returns it. Otherwise, this returns a singleton list containing `x`.
  • Function NEWSYM (&optional (prefix "x"))
    Create a new uninterned symbol whose print name begins with `prefix', which may be a string or a symbol. This differs from `gensym' in that the prefix is not sticky.
  • Function EXPORT-EXPORTED-SYMBOLS (from-package to-package)
    Make the exported symbols in from-package be also exported from to-package.
  • Generic-Function LENGTH-AT-LEAST-P (thing length)
    Returns true if thing has no fewer than length elements in it.
  • Method LENGTH-AT-LEAST-P ((thing sequence) length)
  • Method LENGTH-AT-LEAST-P ((thing cons) length)
  • Generic-Function LENGTH-AT-MOST-P (thing length)
    Returns true if thing has no more than length elements in it.
  • Method LENGTH-AT-MOST-P ((thing sequence) length)
  • Method LENGTH-AT-MOST-P ((thing cons) length)
  • Function LENGTH-1-LIST-P (x)
    Is x a list of length 1? Note that this is better than the naive (= (length x) 1) because we don't need to traverse the entire list...
  • Function NEARLY-ZERO-P (x &optional (threshold 1.e-4))
    Returns true if `x` is within threshold of 0d0.
  • Function NEARLY-EQUAL-P (x y threshold)
    Returns true if x and y are within threshold of each other.
  • Function DOTTED-PAIR-P (putative-pair)
    Returns true if and only if `putative-pair` is a dotted-list. I.e., if `putative-pair` is a cons cell with a non-nil cdr.
  • Function APPLY-IF-EXISTS (function package &rest args)
    If the function `function` can be found in `package`, then apply it to `args`. Returns nil if `package` does not exist or if `function` does not name a function in `package`. Otherwise, returns whatever `function` returns.
  • Function FUNCALL-IF-EXISTS (function package &rest args)
    If the function `function` can be found in `package`, then funcall it on `args`. Returns nil if `package` does not exist or if `function` does not name a function in `package`. Otherwise, returns whatever `function` returns.
  • Function ITERATE-OVER-INDEXES (symbol-counts fn &optional (direction :left))
    Apply fn to lists of indexes generated from symbol counts. The counting is done so that the first symbol varies most quickly unless the optional direction parameter is set to :right.
  • Variable +WHITESPACE-CHARACTERS+
    (list #\  #\newline #\tab #\page #\nul #\newline #\return)
    A list of characters that should be treated as whitespace. See, for example, [whitespacep][].
  • Function WHITESPACEP (char)
    Returns true if `char` is an element of [+whitespace-characters+][] and nil otherwise.
  • Function STRING-STARTS-WITH (string prefix &key test)
    Returns true if `string` starts with `prefix`. Use the keyword argument `test` (which defaults to `char=`) to check each character.
  • Function STRING-ENDS-WITH (string suffix &key test)
    Returns true if `string` starts with `prefix`. Use the keyword argument `test` (which defaults to `eql`) to check each character.
  • Function STRING-TRIM-IF (predicate string &key (start 0) (end (length string)))
  • Function STRIP-WHITESPACE (string &key (start 0) (end (length string)))
  • Macro NYI (&rest args)
    Signals an error saying that this function is not yet implemented. The args are ignored, but by supplying args from the calling function, you can get them ignored by the compiler.
  • Macro DEPRECATED (&body body)
    Wrap a function definition with `deprecated' to indicate that it should no longer be used. If the first element of body is a string, it will be used as additional documentation in the deprecation message. Foo example, (deprecated "Use bar instead." (defun foo-1 (x) (format t "~%FOO: ~A" x))) Will generate the message: ; warning FOO-1 has been deprecated. Use bar instead. at compile time whereever foo-1 is used.
  • Macro ONCE-ONLY (variable-list &body body)
    Generate code that evaluates certain expressions only once. This is used in macros, for computing expansions. VARIABLE-LIST is a list of symbols, whose values are subexpressions to be substituted into a larger expression. BODY is what uses those symbols' values and constructs the larger expression. ONCE-ONLY modifies BODY so that it constructs a different expression, which when run will evaluate the subsexpressions only once, save the values in temporary variables, and use those from then on. Example: (DEFMACRO DOUBLE (ARG) `(+ ,ARG ,ARG)) expands into code that computes ARG twice. (DEFMACRO DOUBLE (ARG) (ONCE-ONLY (ARG) `(+ ,ARG ,ARG))) will not.
  • Macro WITH-VARIABLES (symbols &body body)
    Using gensyms is necessary to prevent variables produced by macro expansions from interfering with user variables, and naming them mnemonically helps make macro expansions and compiled code easier to read, but it's a pain to create them properly. This macro creates them for you, which makes writing nice macros easier. For example, if you are writing a macro to iterate over an array, you used to have to write: (defmacro do-2d-array ((elt array) &body body) (let ((row (gensym "ROW")) (col (gensym "COL"))) `(dotimes (,row (array-dimension 0)) (dotimes (,col ,(array-dimension 1)) (let ((,elt (aref ,array ,row ,col))) . ,body))))) Now you can just write the following, which eliminates the need to laboriously create the mnemonic gensyms. (defmacro do-2d-array ((elt array) &body body) (with-variables (row col) `(dotimes (,row ,(array-dimension 0)) (dotimes (,col ,(array-dimension 1)) (let ((,elt (aref ,array ,row ,col))) . ,body))))
  • Macro EVAL-ALWAYS (&body body)
    Expands into an eval-when with all the fixings. It's nothing but a shorthand.
  • Macro DEFCLASS-PROPERTY (property &optional (default nil default-supplied?))
    Create getter and setter methods for 'property' on symbol's property lists.
  • Macro WITH-ATOMIC-EXECUTION (&body forms)
  • Macro HANDLER-BIND* (binds &rest body)
    Special handler-bind which allow two special control contructs inside of the condition handlers. resume will resume execution past the handler-bind*. retry will execute the code from body, i.e. so you usually fix the problem and then call retry.
  • Macro WITH-GENSYMS (syms &body body)
  • Variable *FILE-IF-EXISTS*
    :supersede
    Default behavior to use when opening files if they already exist.
  • Macro WITH-NEW-FILE ((stream pathname &rest args &key (reset-io t) (print-right-margin *file-print-right-margin*) &allow-other-keys) &body body)
  • Macro WITH-STREAM-FROM-SPECIFIER ((stream stream-specifier direction &rest args) &body body)
  • Macro WITH-INPUT ((var source &rest args) &body body)
    Create an input stream from source and bind it to var within the body of the with-input form. The stream will be closed if necessary on exit.
  • Macro WITH-OUTPUT ((var destination &rest args) &body body)
    Create an output stream from source and bind it to var within the body of the with-output form. The stream will be closed if necessary on exit.
  • Macro MUFFLE-REDEFINITION-WARNINGS (&body body)
    Evaluate the body so that redefinition warnings will not be signaled. (suppored in Allegro, Clozure CL, CLisp, and Lispworks)
  • Function LINEARIZE-ARRAY (array)
  • Function COPY-ARRAY (array)
  • Function MAPARRAY (array fn)
  • Function MAPARRAY! (array fn)
  • Function ARRAY-ROW (array row)
    Returns the row'th row of array. Array is assumed to be two dimensional and row is assumed to be in range. The returned array shared structure with the array parameter.
  • Variable *SAMEP-TEST*
    #'equal
    Used by samep to determine if two things are 'the same'. Defaults to #'equal
  • Generic-Function SAMEP (thing-1 thing-2)
    Compares two things and returns true if they are the same in the sense of being interchangable. Implementations use the special variable *samep-tolerance* to specify how close two things need to be in order to be 'the same'. See nearly-samep too.
  • Method SAMEP ((thing-1 string) (thing-2 string))
  • Method SAMEP ((thing-1 string) (thing-2 string))
  • Method SAMEP ((thing-1 string) (thing-2 string))
  • Method SAMEP ((thing-1 real) (thing-2 real))
  • Method SAMEP ((thing-1 real) (thing-2 real))
  • Method SAMEP ((thing-1 real) (thing-2 real))
  • Method SAMEP ((thing-1 number) (thing-2 number))
  • Method SAMEP ((thing-1 number) (thing-2 number))
  • Method SAMEP ((thing-1 number) (thing-2 number))
  • Method SAMEP ((thing-1 integer) (thing-2 integer))
  • Method SAMEP ((thing-1 integer) (thing-2 integer))
  • Method SAMEP ((thing-1 integer) (thing-2 integer))
  • Method SAMEP (thing-1 thing-2)
  • Method SAMEP (thing-1 thing-2)
  • Method SAMEP (thing-1 thing-2)
  • Generic-Function NEARLY-SAMEP (thing-1 thing-2 tolerance)
    Compares two things and returns true if they are the same in the sense of being interchangable. Tolerance indicates how close things need to be in order to be 'the same'.
  • Method NEARLY-SAMEP (thing-1 thing-2 (tolerance number))
  • Method NEARLY-SAMEP (thing-1 thing-2 (tolerance number))
  • Method NEARLY-SAMEP (thing-1 thing-2 (tolerance number))
  • Condition INVALID-STREAM-SPECIFIER-ERROR  (ERROR)
  • Function INVALID-STREAM-SPECIFIER-ERROR (specifier direction &optional args)
  • Function PHYSICAL-PATHNAME-DIRECTORY-SEPARATOR
    Returns a string representing the separator used to delimit directories in a physical pathname. For example, Digitool's MCL would return ":" whereas OpenMCL would return "/".
  • Function RELATIVE-PATHNAME (relative-to pathname &key name type)
  • Function DIRECTORY-PATHNAME-P (pathname)
  • Function ENSURE-DIRECTORY-PATHNAME (pathname)
  • Function PATHNAME-SAMEP (p1 p2)
    Returns true if the logical translations of `p1` and `p2` have the same (`string=`) namestrings.
  • Function MAP-FORMS (input fn &key (ignore-read-errors-p t))
  • Function MAP-LINES (input fn &key include-empty-lines-p filter)
  • Function COLLECT-FORMS (input &key filter transform)
  • Function COLLECT-LINES (input &rest args &key count-empty-lines-p filter transform)
  • Function MAP-MATCHING-FILES (root expression fn &key max-depth)
  • Function COLLECT-MATCHING-FILES (root expression &key max-depth)
  • Function FILE-NEWER-THAN-FILE-P (file1 file2)
    Compares the write dates of `file1' and `file' and returns t if `file' is newer than `file2' or if it cannot be determined. `file1' is usually the source file and `file2' the object file.
  • Function PATHNAME-WITHOUT-NAME+TYPE (pathname)
    Chop off any name and type information from a pathname.
  • Variable +MINUTES-PER-HOUR+
    60
    The number of minutes in one hour.
  • Variable +SECONDS-PER-MINUTE+
    60
    The number of seconds in one minute.
  • Variable +USUAL-DAYS-PER-YEAR+
    365
    The number of days in an ordinary year.
  • Variable +SECONDS-PER-HOUR+
    (* metabang.utilities:+seconds-per-minute+
       metabang.utilities:+minutes-per-hour+)
    The number of seconds in one hour.
  • Variable +HOURS-PER-DAY+
    24
    The number of hours in one day.
  • Variable +SECONDS-PER-DAY+
    (* metabang.utilities:+hours-per-day+ metabang.utilities:+seconds-per-hour+)
    The number of seconds in one day.
  • Function TIME-SECOND (&optional (universal-time (get-universal-time)) (time-zone nil))
    Returns the second part of the given time.
  • Function TIME-MINUTE (&optional (universal-time (get-universal-time)) (time-zone nil))
    Returns the minute part of the given time.
  • Function TIME-HOUR (&optional (universal-time (get-universal-time)) (time-zone nil))
    Returns the hour part of the given time.
  • Function TIME-DATE (&optional (universal-time (get-universal-time)) (time-zone nil))
    Returns the date part of the given time.
  • Function TIME-MONTH (&optional (universal-time (get-universal-time)) (time-zone nil))
    Returns the month part of the given time.
  • Function TIME-YEAR (&optional (universal-time (get-universal-time)) (time-zone nil))
    Returns the year part of the given time.
  • Function TIME-DAY-OF-WEEK (&optional (universal-time (get-universal-time)) (time-zone nil))
    Returns the day-of-week part of the given time.
  • Function TIME-DAYLIGHT-SAVINGS-TIME-P (&optional (universal-time (get-universal-time)) (time-zone nil))
    Returns the daylight-savings-time-p part of the given time.
  • Function DAYS-IN-MONTH (month &optional leap-year?)
    Returns the number of days in the specified month. The month should be between 1 and 12.
  • Function LEAP-YEAR-P (year)
    Returns t if the specified year is a leap year. I.e. if the year is divisible by four but not by 100 or if it is divisible by 400.
  • Function DAY-OF-YEAR (date &optional time-zone)
    Returns the day of the year [1 to 366] of the specified date [which must be (CL) universal time format.]
  • Function FORMAT-DATE (format date &optional stream (time-zone nil tz-supplied?))
    Formats universal dates using the same format specifiers as NSDateFormatter. The format is: %% - A '%' character %a - Abbreviated weekday name %A - Full weekday name %b - Abbreviated month name %B - Full month name %c - Shorthand for "%X %x", the locale format for date and time %d - Day of the month as a decimal number [01-31] %e - Same as %d but does not print the leading 0 for days 1 through 9 [unlike strftime[], does not print a leading space] %F - Milliseconds as a decimal number [000-999] %H - Hour based on a 24-hour clock as a decimal number [00-23] %I - Hour based on a 12-hour clock as a decimal number [01-12] %j - Day of the year as a decimal number [001-366] %m - Month as a decimal number [01-12] %M - Minute as a decimal number [00-59] %p - AM/PM designation for the locale %S - Second as a decimal number [00-59] %w - Weekday as a decimal number [0-6], where Sunday is 0 %x - Date using the date representation for the locale, including the time zone [produces different results from strftime[]] %X - Time using the time representation for the locale [produces different results from strftime[]] %y - Year without century [00-99] %Y - Year with century [such as 1990] %Z - Time zone name [such as Pacific Daylight Time; produces different results from strftime[]] %z - Time zone offset in hours and minutes from GMT [HHMM] None of %c, %F, %x, %X, %Z are implemented.
  • Function DAY->STRING (day-of-the-week &optional (format :long))
    Returns the name of `day-of-the-week`. The parameter should be a number between 0 and 6 where 0 represents Sunday and 6 repressents Saturday. The optional format argument can be either :long or :short. In the latter case, the return string will be of length three; in the former it will be the complete name of the appropriate day.
  • Function MONTH->STRING (month &optional (format :long))
    Returns the name (in English) of the month. Format can be :long or :short.
  • Function SET-EQUAL (list1 list2 &rest args &key test key)
    Returns t if list1 and list2 are equal (as sets). If list1 and list2 are not equal returns (as multiple values) nil and two lists. The first list contains the elements in list1 and not in list2 and the second list contains elements in list2 and not in list1.
  • Function DEFAULT-INTERFACE
    Return the current default interface (this is setfable).
  • Function (setf DEFAULT-INTERFACE) (value)
  • Generic-Function IS-INTERFACE-AVAILABLE-P (interface-name)
    Returns true is interface-name is available.
  • Method IS-INTERFACE-AVAILABLE-P ((interface (eql nil)))
  • Function IS-DEFAULT-INTERFACE-AVAILABLE-P
  • Generic-Function QUIT-LISP* (interface)
    Quits Lisp
  • Method QUIT-LISP* (interface)
  • Function QUIT-LISP
  • Generic-Function TOTAL-BYTES-ALLOCATED* (interface)
  • Method TOTAL-BYTES-ALLOCATED* (interface)
  • Method TOTAL-BYTES-ALLOCATED* (interface)
  • Method TOTAL-BYTES-ALLOCATED* (interface)
  • Function TOTAL-BYTES-ALLOCATED
    Returns the total number of bytes that this Lisp session has allocated.
  • Function GC-TIME
    Returns the total amount of time that this Lisp session has spent in garbage collection.
  • Generic-Function COLLECT-GARBAGE* (interface)
  • Function COLLECT-GARBAGE
    Tell lisp that now is a good time to collect any accumulated garbage.
  • Macro MAKE-LOAD-FORM* (class-name)
  • Variable *DEVELOPMENT-MODE*
    t
  • Variable *USE-NATIVE-DEBUGGER*
    nil
  • Macro WITH-PROGRESS-BAR ((min max &rest args &key (title "progress") (verbose? t) (desired-interface nil interface-supplied?) (determinate-p t) &allow-other-keys) &body body)
  • Macro WITH-PROCESS-MESSAGE ((&rest args &key (title "please wait...") &allow-other-keys) &body body)
  • Macro HANDLE-ERRORS (standard-message &body body)
  • Function INTERFACE-BEEP (&rest args)
  • Method MAKE-PROGRESS-BAR (interface min max title &key &allow-other-keys)
  • Method PROGRESS-BAR-VALUE (interface bar)
  • Method (setf PROGRESS-BAR-VALUE) (value interface bar)
  • Method CLOSE-PROGRESS-BAR (interface bar)
  • Function GUI-ERROR (condition &optional (prefix "") (standard-message nil))
  • Function GUI-WARN (string &rest args)
  • Function MAKE-COLOR* (red green blue)
    given red, green, and blue, returns an encoded rgb value
  • Function MAKE-GRAY (level)
  • Function MAKE-SCALED-COLOR (red green blue scale)
  • Function Y-OR-N-QUESTION (message &rest args)
  • Function CHOOSE-FILE-QUESTION (&rest args)
  • Function CHOOSE-NEW-FILE-QUESTION (&rest args)
  • Function CHOOSE-DIRECTORY-QUESTION (&rest args)
  • Function CHOOSE-ITEM-QUESTION (list &rest args &key &allow-other-keys)
  • Function CHOOSE-ITEM-FROM-PUP (the-list &rest args &key &allow-other-keys)
    Present an interface to allow a choice from a list. Can throw :cancel.
  • Function CHOOSE-ITEM-FROM-PUP-NO-SINGLETONS (the-list-or-atom &rest args &key &allow-other-keys)
    Like choose-item-from-pup, but just returns the datum if it is an atom or a singleton list.
  • Method MAKE-UI-POINT* (interface x y)
  • Function PROCESS-PARAMETERS (&rest args)
  • Function PUT-ITEM-ON-CLIPBOARD (thing)
  • Method INSPECT-THING* (interface thing &rest args)
  • Function INSPECT-THING (thing &rest args)
  • Function INSPECT-THINGS (&rest things)
  • Function SOUND-NOTE (pitch velocity &rest args)
  • Function STOP-NOTES
  • Function SELECT-INSTRUMENT (instrument &rest args)
  • Function QUERY-USER-FOR-STRING (prompt &rest args &key &allow-other-keys)
  • Function QUERY-USER-FOR-INTEGER (prompt &optional minimum maximum)
  • Function PROMPT-FOR (type message &rest args)
  • Function PARSE-BRIEF-SLOT (slot &optional (automatic-accessors? *automatic-slot-accessors?*) (automatic-initargs? *automatic-slot-initargs?*) name-prefix name-postfix (name-separator "-") (additional-options nil))
    Returns a verbose-style slot specification given a brief style, consisting of a single symbol, the name of the slot, or a list of the slot name, optional initform, optional symbol specifying whether there is an initarg, reader, or accessor, and optional documentation string. The specification of initarg, reader and accessor is done by the letters I, R and A, respectively; to specify none of those, give a symbol containing none of those letters, such as the symbol *. This function is used in the macro `defclass-brief,' but has been broken out as a function in its own right for those writing variants on the `defclass' macro. If a verbose-style slot specification is given, it is returned unchanged. If `automatic-accessors? is true, an accessor is defined, whether A is specified or not _unless_ R is specified. If `automatic-initargs? is true, an initarg is defined whether I is specified or not. If `name-prefix' or `name-postfix' is specified, the accessor name has that prepended or appended, with name-separator, and the slot name in the middle. All other CLOS slot options are processed normally.
  • Macro DEFCLASS-BRIEF (name superclasses slots &rest class-options)
    A macro with simpler syntax than `defclass' that allows some briefer ways of expressing things. The syntax is more like `defstruct.' A documentation string is optional. Each slot is expressed as either a bare symbol, or a list of the name of the slot, its initial value, a symbol with the letters I, R, A, standing for :initarg, :reader and :accessor, and a documentation string. The symbol, whose package is unimportant, determines the generation of reader, accessor and so forth; the names are the same as the slot name. All other CLOS options are processed normally. In addition, three new class options are defined. :AUTOMATIC-ACCESSORS means that an accessor is defined for every slot :AUTOMATIC-INITARGS means that an initarg is defined for every slot (:NAME-PREFIX <symbol> <separator>) (:NAME-POSTFIX <separator> <symbol>) prepends or appends `symbol' with `separator' to each slot accessor. The default symbol is the class name and the default separator is the hypen, in which case the wrapping parentheses are optional.
  • Function CLASS-COPYABLE-P (class-name)
  • Macro DEFCLASS* (name superclasses slots &rest class-options)
    Like 'defclass-brief' but also provides the :MAKE-LOAD-FORM-P, :EXPORT-P, :EXPORT-SLOTS, :NO-COPY, :COPY-SLOTS and :COPY-SET-SLOTS options.
  • Macro DEFCONDITION (name supers slots &rest options)
    Defcondition is a handy shortcut for defining Common Lisp conditions. It supports all of #[H][define-condition]'s options and more.
  • Condition SOURCE/TARGET-FILE-ERROR  (FILE-ERROR)
    General condition for file errors that have a source and target.
  • Condition SOURCE/TARGET-TARGET-ALREADY-EXISTS-ERROR  (SOURCE/TARGET-FILE-ERROR)
    This error is signaled when the target pathname already exists.
  • Condition SOURCE/TARGET-SOURCE-DOES-NOT-EXIST-ERROR  (SOURCE/TARGET-FILE-ERROR)
    This error is signaled when the source file does not exist.
  • Function COPY-FILE (from to &key (if-does-not-exist :error) (if-exists :error))
    Copies the file designated by the non-wild pathname designator FROM to the file designated by the non-wild pathname designator TO. The following keyword parameters are supported: * :if-exists this can be either :supersede or :error (the default). If it is :error then a source/target-target-already-exists-error will be signaled if the file designated by the TO pathname already exists. * :if-does-not-exist this can be either :ignore or :error (the default). If it is :error then a source/target-source-does-not-exist-error will be signaled if the FROM pathname designator does not exist.

Also exports

  • ASDF/LISP-ACTION:LOAD-OP
  • ASDF/LISP-ACTION:TEST-OP
  • SB-MOP:CLASS-PRECEDENCE-LIST
  • SB-SYS:WITHOUT-INTERRUPTS
  • ASDF/OPERATE:OOS
  • SB-MOP:FINALIZE-INHERITANCE
  • ASDF/OPERATE:OPERATE
  • SB-MOP:CLASS-FINALIZED-P
  • ASDF/LISP-ACTION:COMPILE-OP
  • SB-MOP:CLASS-DIRECT-SUBCLASSES