[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

String copying

    Date: 9 January 1982 20:50-EST
    From: David L. Andre <DLA at MIT-AI>

        Date: 9 January 1982 00:19-EST
        From: Kent M. Pitman <kmp at MIT-AI>

        In System 78.33, ... microcode 836, ... on Lisp Machine Twenty-two:

        Is it a feature of STRING-RIGHT-TRIM (and SUBSTRING, for that matter) return
        copies of the input string rather than the original in the case where a 
        string EQUAL to the input is to be generated?
    It seems pretty clear in the documentation that this is so.

It seems pretty clear that it happens, but it was far from clear that the
implementors intended it to be a guaranteed feature which code should
be relying on. It's a really awful thing to have built into the semantics of
the primitive. I concur with GJC's remarks about this encouraging poor programming

        There should be a COPYSTRING function available for people who need a fresh
        copy of the string.
    STRING-APPEND is what you want.

No, STRING-APPEND may be all that is offered, but COPYSTRING is what I want.
I think the (APPEND frob nil) class of idioms is pretty dumb-looking. I assume
that's why the LispM offers COPYLIST instead of making the guy say something
awful like (APPEND obj NIL ':AREA area). In any case, the existence of this 
function was not my point...

My point was -- as GJC correctly guessed -- that if STRING-RIGHT-TRIM
didn't copy, it would be easy for me to write a version that did. Given that it
does copy, I'm forced to go back to STRING-SEARCH and SUBSTRING to write a non-
copying version... The RIGHT base primitive to offer should be the simplest. 
Fine if you want to provide both functionalities, but please include the easy
one in an easy way so users don't have to waste their time re-inventing existing