Am Mo., 9. März 2020 um 17:30 Uhr schrieb Per Bothner <xxxxxx@bothner.com>:
On 3/8/20 2:58 PM, John Cowan wrote:

> By the same token (and this is why I have also copied xxxxxx@ on this email), incorporating SRFI-140 into R7RS-large violates the charter requirements, in my judgment.

Charter requirements are less of a concern to me that what is better for the Scheme language
and community in the long run.

You have a point here.

There can be design errors of R7RS-small.  Do we have to live with them or can we correct them?  By the charter, the initial idea was seemingly to develop both the small and large language in parallel.  If this had happened, we wouldn't have had the keyword syntax problem and, maybe, the string problem as well.
 

>  The value of (string-set! (string-upcase (string #\a \#b \#c) 1 #\!) is defined by R7RS-small as "A!C".  But in a SRFI-140 world, string-upcase returns an immutable string and so the string-set! call fails.

I guess it is *possible* to write a correct and meaningful program that that calls string-set!
on the result of string-upcase but I find that very hard to conceive of.
So I think the concern with breaking program is valid, but string-upcase is ulikely
to be an issue.

While breaking old programs is unfortunate, srfi-140 is the best kind of incompatibility:
Programs break cleanly (compile-time or run-time type-checking rather than wrong result or
hard-to-detect performance degradation); the fix is local and trivial (usually add a call
to string-copy); and the fixed programs work fine on older implementations.

In my limited experience after making strings by default immutable, there were very few
places I had to fix my code.

It would be helpful if someone had larger programs that use strings, and tried running
then with srfi-140 - perhaps using Kawa.  I'd like to know if you had to change much,
and if it was difficult to do so.

On 3/9/20 12:42 AM, Marc Nieper-Wißkirchen wrote:
> I agree with the problem the SRFI 140 string procedures have.  The base language (R7RS-small) would have to be evolved first.  The approach to call immutable strings something else (like `text's) seems the best way out.

That would be an absolute disaster.  It would break *every* existing string-using program,
not in the sense of no longer working, but in the sense of using a deprecated/obsolete API,
as well as performance issues for programs that are not updated.

Hmmm... I didn't mean to deprecate/obsolete the old API or the old mutable strings.  In fact, I would extend their mutability.  At the moment, we do have R7RS-small strings that have two problems: (1) They are not immutable, making most code unnecessarily inefficient.  (2) The are not mutable enough.

By (2), I mean that if you ask for mutable strings, you usually want more than just the ability to change characters in a string.  For example, you want to be able to delete or insert characters as well.

If we narrow R7RS-small strings so that problem (1) is solved, we violate backward compatibility.  On the other hand, we can easily extend R7RS-small strings to something that, say, can eventually represent Emacs buffers, thus solving (2).  If we go this route, we need some new name for immutable strings.  We would end up with "texts" and "strings", which would probably be named "strings" and "buffers" if we didn't maintain backward compatibility.

Even in the case of maintaining backward compatibility, I would propose some reader flag so that strings enclosed in quotes will be read as immutable strings (whatever they are called), because most string constants wouldn't end up as general mutable buffers.

Marc


How do you visualize the state of Scheme if the new standard recommends text-upcase etc
in place of string-upcase etc?  How will tutorials and other documents be changed?  Who
will change their existing programs to use the new text-xxx APIs?  My guess is almost nobody.

Either leave strings R7RS-large unchanged from R7RS-small (perhaps with a deprecation
warning), or some variant of srfi-152 (also perhaps with a deprecation warning), or
go with srfi-140 (possibly with some tweaking).  srfi-135 would be a disaster, IMO.

--
        --Per Bothner
xxxxxx@bothner.com   http://per.bothner.com/

--
You received this message because you are subscribed to the Google Groups "scheme-reports-wg2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xxxxxx@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scheme-reports-wg2/7d2ae20c-2cf0-36d7-ce58-7d5ef153c1c2%40bothner.com.