Re: using a character as argument to string-append!/string-append-linear! Per Bothner (18 Apr 2020 14:52 UTC)

Re: using a character as argument to string-append!/string-append-linear! Per Bothner 18 Apr 2020 14:52 UTC

On 4/18/20 6:12 AM, John Cowan wrote:
> Hmm.  What do you think about adding a vector containing characters

I don't see enough use for that.  For Kawa you can just write:
    (string-append! sbuf @cvec)

> and/or a textual input port as additional sources?

Perhaps it would make sense in some other languages, but not Scheme.

> Once we are no longer monomorphic, I'm open to additional possibilities

In some languages (JavaScript comes to mind) there is no separate character type - a
character is just a string of length 1.  I think that makes a lot of sense, especially
in a Unicode world where that is a "character" (or Unicode scalar value) is somewhat
arbitrary.  I think it would be possible (and probably useful) to design a Scheme
where character is a sub-type of string what remaining very compatible with
traditional Scheme, except that (equal? "X" \X).

So even if character is not a subtype of string formally speaking, in an informal
way they are.  So it wold not be reasonable to allow characters in some (or all)
places where a string is allowed.

Another point:  I could argue that:
     (string-append! str ch)
is a more "fundamental" operation thatn:
     (string-append! str str2)
so the former is higher priority to provide.
--
	--Per Bothner
xxxxxx@bothner.com   http://per.bothner.com/