From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Per Bothner Newsgroups: gmane.lisp.guile.user Subject: Re: null terminated strings Date: Mon, 19 Jan 2004 10:46:35 -0800 Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Message-ID: <400C260B.8050306@bothner.com> References: <87oet4ntsm.fsf_-_@ID-28718.user.uni-berlin.de> <1074245327.6733.9.camel@localhost> <87u12wjiy7.fsf@ID-28718.user.uni-berlin.de> <1074250929.6734.63.camel@localhost> <87eku0f5em.fsf@ID-28718.user.uni-berlin.de> <5.2.0.9.2.20040119120825.0a4d48c8@zima.bbn.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1074538329 21681 80.91.224.253 (19 Jan 2004 18:52:09 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 19 Jan 2004 18:52:09 +0000 (UTC) Cc: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jan 19 19:51:58 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AieVC-0002K9-00 for ; Mon, 19 Jan 2004 19:51:58 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AieRR-0000z6-Hj for guile-user@m.gmane.org; Mon, 19 Jan 2004 13:48:05 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AieQz-0000wT-V3 for guile-user@gnu.org; Mon, 19 Jan 2004 13:47:37 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AieQT-0008OQ-6F for guile-user@gnu.org; Mon, 19 Jan 2004 13:47:36 -0500 Original-Received: from [64.164.98.56] (helo=mtaw6.prodigy.net) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AieQP-0008ND-H4 for guile-user@gnu.org; Mon, 19 Jan 2004 13:47:01 -0500 Original-Received: from bothner.com (adsl-216-102-199-253.dsl.snfc21.pacbell.net [216.102.199.253]) by mtaw6.prodigy.net (8.12.10/8.12.10) with ESMTP id i0JIjoFA000308; Mon, 19 Jan 2004 10:45:54 -0800 (PST) User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en Original-To: Ken Anderson In-Reply-To: <5.2.0.9.2.20040119120825.0a4d48c8@zima.bbn.com> X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.user:2651 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:2651 Ken Anderson wrote: > In Java, which does copy-on-write String (including substrings) are immutable, so they cannot be written. The implementation of the StringBuffer class does do copy-on-write, but that doesn't affect substrings. > i often find myself carefully copying the substrings so they don't share structure. Why? The only reason I can think of is garbage collection: A shared substring prevents the base from being collected. > This is because of things like: > - i don't know how long the underlying string (char array actuall) is. So? > Java only has one kind of string, which is fairly heavy weight. For example, the string "" takes 36 bytes: > >>(describe "") > is an instance of java.lang.String > > // from java.lang.String > value: [C@d42d08 > offset: 0 > count: 0 > hash: 0 This depends on the implementation, and the version of the implementation. GCJ uses for "": object header (4 bytes on 32-but systems) private Object data; /* points to itself in this case */ private int boffset; /* offset of first char within data */ int count; /* number of character */ private int cachedHashCode; /* chars follow if data==this */ (The data and boffset fields are only accessed by native C++ code.) Total 20 bytes. -- --Per Bothner per@bothner.com http://per.bothner.com/ _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user