ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
Unrevised from 8.1 to 8.2.
8.1 version

String utility functions in Allegro CL

This document contains the following sections:

1.0 Operators in the util-string module

The util-string module is designed to contain operators which extend standard Common-Lisp string functionality in ways that are faster, more efficient, or more convenient. The initial release of this module contains the single operator string+.

Symbols in the util-string module are in the util.string package. You load the module with the form

(require :util-string)


1.0 Operators in the util-string module


string+

Function

Package: util.string

Arguments: &rest objects

string+ returns a fresh simple string that contains the printed representation of all the individual objects passed as arguments in the order that they are supplied. Actual strings among objects are copied into the result string. Other objects are made into strings as if they were passed to princ-to-string (although the actual mechanism may be different for some types of objects), with *print-pretty* bound to nil. This function is designed to allow string to be used as identifiers or labels to be created quickly and efficiently.

string+ called with no arguments returns the null string "".

The aim of string+ is to be much more efficient than (format nil "..." ...) and more flexible than cl:concatenate. string+ is highly optimized for the following types:

You may not see the same speed or space efficiencies if other types of objects are included.

string+ is also optimized for smaller strings. Creating large strings will also not show much speed improvement over cl:format although it is easier to call.

No action is taken by string+ to ensure that the values of the various print variables other than *print-pretty* (like, for example, *print-array*) are appropriate for providing information about the associated object in the string (see the example using *print-array*). If you want better control over how objects of types other than those listed above, such as arrays, floats (which are also affected by variables like *read-default-float-format*), lists, and so on, are included, consider passing the desired print representation as an argument rather than the object or using format in place of string+.

Examples

(use-package :util.string)
(string+ 1 2 3 4 5) RETURNS "12345"
(string+)  RETURNS ""
(setq a "new string")
(setq b (string+ a)) RETURNS "new string"
(eq a b) RETURNS nil

(string+ 1 #\space 2 #\- 3 "=" 4 :x 5) RETURNS "1 2-3=4x5"

(let ((*print-base* 8))
  (string+ 16))
  RETURNS "20"  ;;  *print-base* etc. are respected

;; How more complex objects are stringified depends on things,
;; like print variables, which are not set by STRING+,
;; as this vector example shows:

(setq my-vec (vector 1 2 3 4))
(let ((*print-array* t))
  (string+ my-vec))
    RETURNS "#(1 2 3 4)"
(let ((*print-array* nil))
  (string+ my-vec))
    RETURNS "#<Vector>"


Copyright (c) 1998-2016, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.1 page.
Created 2010.1.21.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
Unrevised from 8.1 to 8.2.
8.1 version