[bitc-dev] Primary string type
Jonathan S. Shapiro
shap at eros-os.org
Fri May 19 01:04:40 EDT 2006
On Fri, 2006-05-19 at 00:01 -0400, Swaroop Sridhar wrote:
> Jonathan S. Shapiro wrote:
> > On Thu, 2006-05-18 at 23:38 -0400, Swaroop Sridhar wrote:
> >
> >>I just noticed that the string type is not listed in
> >>Section 3.2 Primary Types. This is probably because we initially defined
> >>string as (vector char) but subsequently changed over to a primitive
> >>string type.
> >
> >
> > String isn't a primary type. It is a sequence type.
> >
> > That having been said, I agree that it needs to be added. However, what
> > to add is not straightforward. We need first to discuss string literals
> > and their relationship to mutability.
>
> If I write:
>
> (define x:(mutable string) "abcd")
>
> and then if we say:
>
> (set! x "efgh")
>
> x now points to a different string. x was mutated, not the string. In
> the same sense,
>
> (define y "efgh")
>
> (set! x y)
>
> x and y can point to (since strings cannot be unboxed) the same string.
>
> Also, the total memory consumption in this system is constant because
> once the string literals are created, copies only need to point to
> existing strings. Am I missing something?
Possibly yes, because there is a question about whether a string literal
is a shorthand for an application, in which case copies may not point to
existing strings. See my note coming out momentarily.
> However, by string-set!, do you mean that parts of the string can be
> overwritten?
If strings are sequences of mutable characters, then yes. The (mutable
string) test isn't relevant to the question. Your later vector test *is*
relevant.
> If strings are a sequence type, is there a plan to allow indexing into
> strings?
Definitely yes.
shap
More information about the bitc-dev
mailing list