From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20329 invoked from network); 10 Jun 1999 10:28:17 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 10 Jun 1999 10:28:17 -0000 Received: (qmail 1808 invoked by alias); 10 Jun 1999 10:27:56 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6565 Received: (qmail 1799 invoked from network); 10 Jun 1999 10:27:53 -0000 Message-Id: <9906100959.AA40247@ibmth.df.unipi.it> To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: Parameters Date: Thu, 10 Jun 1999 11:59:03 +0200 From: Peter Stephenson This was the list of things I was gathering to do with parameters. Maybe there's not really anything to do, but I thought I'd ask. 1. Arrays. As Andrej has discovered, scripts using a lot of these are pretty inefficient because they are always allocated and freed element by element. You can already sort of pre-extend arrays by doing things like arr[256]=''. But that's not so good: you can't use arr=($arr foo) or arr[$#arr+1]=foo to add elements, since they go in the wrong place, and those blank elements can show up in other places, and they're all allocated as single-byte strings, too. So maybe we should think about allowing arrays to keep their allocated length until they are unset, or maybe something more complicated. 2. Retrieving parameters. I pointed out when I introduced the mapfile module that the shell was doing too much accessing of values, so when you do `vared mapfile[foo]', file foo gets read twice. This could be fixed with an extra set of flags passed down in params.c saying the value is not going to be used and doesn't need to be computed. However, while it only affects a few special parameters, most of which (those already built-in) have farily simple definitions and don't need to be altered much, this is probably an unnecessary lot of work. 3. vared is a bit strange with read-only variables: it lets you edit the value, then announces after you have that it's a read-only parameter and you can't set it. We could deal with this two ways (1) add the phrase `So there.' to the error message just to rub it in (2) test earlier whether it is read-only. I favour (2). 4. On a similar theme, non-existent associative array elements respect the nounset option, but `vared compconfig[nonexistentelement]' doesn't cause an error as it usually would without the -c option. I don't know if this is a feature or not. -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy