[Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]  


strings.[ch]

Status: Finished and somewhat useful.

Description: it does, like, string things, ya know?

Note: true == true value in c, false == false value in c #t and #f as in scheme.

C Macro: SCM_STRINGP (x)
True if x is a SCM object representing a scheme string
C Macro: SCM_NSTRINGP (x)
True if x is not a string object.
C Macro: SCM_RWSTRINGP (x)
True if x can be written to.
C Macro: SCM_NRWSTRINGP (x)
True if x cannot be modified.
Function: read-only-string? str
C Function: SCM scm_read_only_string_p (SCM str)
#t if str is a read-only string (i.e. a shared substring).
C Function: SCM scm_makstr (long len, int slots)
Returns a scheme string of length len, with slots slots with space for scheme values. The pointer to the actual start of this allocated memory is located in the word before the string's chars (so, SCM_CHARS(str)-1 == pointer to the start of slots).
C Function: SCM scm_makfromstrs (int argc, char **argv)
Hey, argc and argv are back! Hi argc and argv!

Anyhow, this creates a scheme list of scheme strings from an array of c strings.

Internal C Function: SCM scm_take0str (char *it)
Returns a string that uses it's storage; that is, it is the string that it points to, and if it is modified, it will be modified as well (oh, the joy of it all ;). Maybe an example ;)
char the_string = "This is a string";
SCM the_scm_string = scm_tak0str(the_string);
SCM_CHARS(the_scm_string)[0] = 't';
printf(the_string);
-|
"this is a string"

C Function: SCM scm_makfromstr (const char *src, scm_sizet len, int slots)
Pretty much the same as scm_makstr, except this one initializes the first len-1 chars from src. Note that it doesn't actually check that src is long enough, so you have to be careful. On the plus side, none of the parameters are named `it'.
C Function: SCM scm_makfrom0str (const char *src)
Another mak function (when SCM was originally written, "e's" were under dispute due to a really stupid patent involving the creators of Sesame Street), this one just calls scm_makfromstr with the src string, the length of the src string, and no slots specfied.
C Function: SCM scm_makfrom0str_opt (const char *src)
Umm ... this is just scm_makfrom0str again ... maybe it's supposed to be optimized? It isn't, though. It kind of looks cooler, though, with makfrom0str sandwiched between scm_ and _opt.
Function: make-shared-substring str [frm [to]]
C Function: SCM scm_make_shared_substring (SCM str, SCM frm, SCM to)
This creates a shared substring of str from frm to to. Currently, a shared substring consists of:
[car] --------->  [cdr] 
type&length         |
                    |
             +------+------+
          [car]          [cdr]
          offset         pointer to `real' string

The storage is shared between the original and the copy. Currently, you cannot (or at least shouldn't) write to the string contained in a shared substring (I believe that the eventual goal is to support copy-on-write shared substrings).


[Contents]   [Back]   [Prev]   [Up]   [Next]   [Forward]