- (string-copy s [start end]) -> stringprocedure
[R5RS+] substring/shared returns a string whose contents are the characters of S beginning with index START (inclusive) and ending with index END (exclusive). It differs from the R5RS substring in two ways:
- The END parameter is optional, not required.
- substring/shared may return a value that shares memory with S or is eq? to S.
string-copy is extended from its R5RS definition by the addition of its optional START/END parameters. In contrast to substring/shared, it is guaranteed to produce a freshly-allocated string.
Use string-copy when you want to indicate explicitly in your code that you wish to allocate new storage; use substring/shared when you don't care if you get a fresh copy or share storage with the original string.
(string-copy "Beta substitution") => "Beta substitution" (string-copy "Beta substitution" 1 10) => "eta subst" (string-copy "Beta substitution" 5) => "substitution"