Vitaly Magerya scripsit:

> John, can you elaborate on such design? Particularity, is there an
> equivalent to string-ref in this model?

String-ref would just be a degenerate case of substring.

We can think of strings in this model as analogous to integers.  We write
down an integer using digits, but we do not normally think of an integer
itself as *being* a sequence of digits, where digits are a different kind
of thing from integers.  If we did have reason to decompose integers into
their digit representations, we'd probably use the integers 0 through
9 for the digits, and not worry about their supposed "dual role".

And just as we typically have immediate representations for an
implementation-chosen range of integers, in this model we'd have an
immediate representation for an implementation-chosen set of strings.
But Scheme programmers wouldn't normally have to deal with that, any
more than they normally have to deal with fixnums vs. bignums today.

In addition, it makes sense in this model for strings to be immutable.
Again an analogy: we don't allow you take an integer and mutate one of
its digits, making it some other integer altogether!  We think of the
integer as a whole atomic value, not a sequence whose components may
sensibly be mutated.

> It seems that substring searching or regexp-matching without chars is
> only doable after you encode a string and store it in a byte array,
> which is not very convenient; any way around that?

Sure.  Don't do it.  :-)  Instead, have a useful set of internal iterators
over strings that pass substrings to a user-specified function.

-- 
John Cowan
        [email protected]
                I am a member of a civilization. --David Brin

_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to