Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:1158 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93297 invoked from network); 2 May 2003 10:57:10 -0000 Received: from unknown (HELO mailout03.sul.t-online.com) (194.25.134.81) by pb1.pair.com with SMTP; 2 May 2003 10:57:10 -0000 Received: from fwd05.sul.t-online.de by mailout03.sul.t-online.com with smtp id 19BYE1-0003L2-05; Fri, 02 May 2003 12:57:09 +0200 Received: from baumbart.post.rwth-aachen.de (520072483730-0001@[80.142.177.233]) by fwd05.sul.t-online.com with esmtp id 19BYDn-0ienRoC; Fri, 2 May 2003 12:56:55 +0200 Reply-to:marcus.boerger@post.rwth-aachen.de Message-ID: <5.1.0.14.2.20030502125524.093ec070@pop.t-online.de> X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Fri, 02 May 2003 12:56:53 +0200 To: "l0t3k" Cc: internals@lists.php.net In-Reply-To: <20030502035725.53049.qmail@pb1.pair.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Sender: 520072483730-0001@t-dialin.net Subject: Re: [PHP-DEV] Object Design question. From: marcus.boerger@t-online.de ((Marcus =?iso-8859-1?Q?B=F6rger?=)) References: <20030502035725.53049.qmail@pb1.pair.com> At 15:02 01.05.2003, l0t3k wrote: >im writing a UnicodeString class for an extension and wanted to ask a >question related to the design of the user-space API. > >the issue is with operations that perform modifications (insert, remove, >padding, etc). we have the java/javascript route where strings are >immutable, meaning that each modification operation creates a new string >while leaving the original unmodified. this has the virtue of being familar >to people (less WTF), though its less efficient. but we may also choose to >do modifications in-place and return a reference to the string. Java is the full WTF overkill-megabloat when it comes to think about memory usage. So please don't do the same mistake! > i copped out for now and provided for having modification methods function >statically as well as non-statically. f. ex. > >// modifies $warAndPeace. $str and $warAndPeace refer to the same string >(1) $str = I18N::UnicodeString::insert($warAndPeace, $editorsNotes, 0); > >// creates $newString, copies $warAndPeace to it, and does the insert >(2) $newString = $warAndPeace->insert($editorsNotes, 0) > >the question is should (2) return a reference to the original which is >modified in place. i think having static/non-static handling may be the way >out, but the concern there is perceived bloatage. static = copy dynamic = inplace