Re: using a character as argument to string-append!/string-append-linear! Per Bothner (17 Apr 2020 16:40 UTC)

Re: using a character as argument to string-append!/string-append-linear! Per Bothner 17 Apr 2020 16:39 UTC

On 4/17/20 9:20 AM, John Cowan wrote:
> Given that this feature was in SRFI 118, I'm willing to add it here, but I'd like to know what the use case for it is.  The example should probably just say (string-append! result "\n") anyway.

The translate-space-to-newline example in SRFI-118 uses:

     (string-append! result ch)

while the SRFI-185

     (string-append! result (string ch))

The former is more concise, (probably) more efficient, more readable, IMO.

FWIW, the java.lang.Appendable interface defines both:

     append(char c)

and

     append(CharSequence csq)

for convenience, though of course either can be expressed in terms of the other.
--
	--Per Bothner
xxxxxx@bothner.com   http://per.bothner.com/