LispWorks default string construction is affected by the value of
lw:*default-character-element-type*
. If the value is
base-char
then:
(make-string 3)
returns a
simple-base-string
. If the value is
lw:simple-char
then the same form returns a
lw:simple-text-string
.
This variable merely provides the default behaviour. If enough information is supplied, then a string of suitable type is constructed. For instance, the form:
(make-string 3 :initial-element #\Ideographic-Space)
constructs a string of a type that can hold its elements, regardless of the value of
lw:*default-character-element-type*
.
Other string constructors also take their default from this variable. For instance, the string reader will always construct a string of type determined by this variable, unless it sees a character of a larger type, in which case a suitable string is constructed.
The initial value of
lw:*default-character-element-type*
is
base-char,
to avoid programs that only require 8-bit strings needlessly creating larger string objects. If your application uses Unicode characters beyond the Latin-1 range (characters of type
extended-char
) then you should consider which of the following two approaches to use:
extended-char
s are constructed explicitly with the appropriate type. This is the conservative approach, allowing you to avoid allocation of 16-bit strings where these are not required. Note that you can use the specialised accessors such as
lw:stchar
for strings of type
lw:simple-text-string
.
(set-default-character-element-type 'lw:simple-char)
Bear in mind that this is a global setting which affects default string construction for the entire system. It could be called from a user interface, depending on whether the user needs to handle
extended-char
s.
lw:*default-character-element-type*.