[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.10.3 String Constructors

Function: make-string k &optional char
[R5RS] Returns a string of length k. If optional char is given, the new string is filled with it. Otherwise, the string is filled with a whitespace. The result string is always complete.

(make-string 5 #\x) => "xxxxx"

Note that the algorithm to allocate a string by make-string and then fills it one character at a time is extremely inefficient in Gauche, and should be avoided. That kind of algorithms unnecessarily assumes underlying string allocation and representation mechanism, which Gauche doesn't follow. You can use an output string port for a string construction (See section 6.18.4 String ports). Even creating a list of characters and using list->string is faster than using make-string and string-set!.

Function: string char ...
[R5RS] Returns a string consisted by char ....

Generic Function: x->string obj
A generic coercion function. Returns a string representation of obj. The default methods are defined as follows: strings are returned as is, numbers are converted by number->string, symbols are converted by symbol->string, and other objects are converted by display.

Other class may provide a method to customize the behavior.

This document was generated by Ken Dickey on November, 28 2002 using texi2html