chicken-hackers
[Top][All Lists]
Advanced

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

[Chicken-hackers] string-append


From: Jim Ursetto
Subject: [Chicken-hackers] string-append
Date: Wed, 18 Mar 2009 22:53:02 -0500

I am curious about the behavior of string-append and substring in the compiler.

(define (foo) (string-append "foo" "bar"))
(eq? (foo) (foo)) ;=> #t

This is because (string-append "foo" "bar") compiles down to the
single literal "foobar", while R5RS says (string-append) returns a
newly allocated copy.  The same is true for (substring "foobar" 0).

I do not mind if this behavior remains for optimization purposes, but
was curious if it is intentional.

I also noticed identical literal strings are not coalesced in the
compiler.  I was interested to know if this is done to ensure these
strings are separate mutable copies, or if it was just not worth the
effort to coalesce them.

Jim




reply via email to

[Prev in Thread] Current Thread [Next in Thread]