From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11815 invoked from network); 5 Mar 2006 17:24:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 5 Mar 2006 17:24:11 -0000 Received: (qmail 62864 invoked from network); 5 Mar 2006 17:24:01 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 5 Mar 2006 17:24:01 -0000 Received: (qmail 14743 invoked by alias); 5 Mar 2006 17:23:58 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22323 Received: (qmail 14733 invoked from network); 5 Mar 2006 17:23:57 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 5 Mar 2006 17:23:57 -0000 Received: (qmail 62538 invoked from network); 5 Mar 2006 17:23:57 -0000 Received: from mta07-winn.ispmail.ntl.com (81.103.221.47) by a.mx.sunsite.dk with SMTP; 5 Mar 2006 17:23:52 -0000 Received: from aamta10-winn.ispmail.ntl.com ([81.103.221.35]) by mta07-winn.ispmail.ntl.com with ESMTP id <20060305172352.PDDD15056.mta07-winn.ispmail.ntl.com@aamta10-winn.ispmail.ntl.com> for ; Sun, 5 Mar 2006 17:23:52 +0000 Received: from pwslaptop.csr.com ([81.105.236.124]) by aamta10-winn.ispmail.ntl.com with ESMTP id <20060305172351.TEMX20857.aamta10-winn.ispmail.ntl.com@pwslaptop.csr.com> for ; Sun, 5 Mar 2006 17:23:51 +0000 Received: from pwslaptop.csr.com (pwslaptop.csr.com [127.0.0.1]) by pwslaptop.csr.com (8.13.4/8.13.4) with ESMTP id k25HNfXG003411 for ; Sun, 5 Mar 2006 17:23:41 GMT Received: from pwslaptop.csr.com (pws@localhost) by pwslaptop.csr.com (8.13.4/8.13.4/Submit) with ESMTP id k25HNdZI003407 for ; Sun, 5 Mar 2006 17:23:41 GMT Message-Id: <200603051723.k25HNdZI003407@pwslaptop.csr.com> X-Authentication-Warning: pwslaptop.csr.com: pws owned process doing -bs From: Peter Stephenson To: "Zsh-workers" Subject: Re: [PATCH][RFC] check for heap memory in zfree() In-Reply-To: Your message of "Sun, 05 Mar 2006 01:13:51 PST." <060305011351.ZM7225@torch.brasslantern.com> Date: Sun, 05 Mar 2006 17:23:39 +0000 Bart Schaefer wrote: > I'm not entirely happy with either of these because both needlessly > duplicate memory in the case where the array is already free-able. > It seems as if it should be possible for "typeset -U" to be made more > efficient than assignment-by-copy. >... > Maybe someone can remind me why it's up to the parameter set-function > to free its argument? That seems completely inside-out to me. This second is the nub of the problem. The API (if that isn't an overgrand way of putting it in this case) requires the value to be assigned permanently. For normal parameters this is typically more efficient (I presume; I haven't followed it through to make sure) since there's no additional copy; it's just assigned to the array variable and the old value is freed. In this case we are doing something slightly suspicious to make a feature implemented rather differently behave like a parameter. Later: > } OR you guys are now going to say: "Don't you know you're not supposed > } to use typeset with dirstack!!" > > You aren't, but the shell isn't supposed to crash, either. Why not? If you weren't supposed to do that kind of thing, dirstack wouldn't be writeable. Since it is, this needs to be handled transparently. If it quacks like a parameter and waddles like a parameter, a user should assume it swims on water like a parameter (er, as it were). It seems to me that behind both of these is the tension between the ability to make a feature look like a parameter and efficiency of implementation for normal parameters. I don't see how we can do both, except with lots of ad hoc testing for specialness, which fixes the problem at the expense of yet more complexity. That is at least the standard zsh way out. -- Peter Stephenson Web page still at http://www.pwstephenson.fsnet.co.uk/