From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16941 invoked from network); 22 May 1999 16:11:23 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 22 May 1999 16:11:23 -0000 Received: (qmail 6150 invoked by alias); 22 May 1999 16:11:14 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6332 Received: (qmail 6143 invoked from network); 22 May 1999 16:11:13 -0000 Message-Id: <9905221525.AA30851@ibmth.df.unipi.it> To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: PATCH: pws-19: associative array interface to files Date: Sat, 22 May 1999 17:25:22 +0200 From: Peter Stephenson This is why I was looking at the parameter module so closely: it's an associative array interface to files, just so that Bart can do `vared mapfile[foo]' to edit the file foo. All the finnicky parameter details are simply copied from parameter.c, which is why Sven is in the copyright as co-author. See the manual page for more details of how to use this (the interface is open to possible criticism). I implemented I/O in what should be an efficient way by using mmap() if available (and provided all the other bits I need for my way of doing things, munmap(), msync(), ftruncate(), are there, too): note that so far I've only tried this on AIX, whose memory management is a bit sui generis, so it's possible the mmap() stuff is going to fail on other systems. However, I hope that in convering AIX I've covered pretty much what the OS writers can throw at it. You can #undef USE_MMAP to compile if you need to to try it out. Unfortunately, zsh's internal memory management is anything but efficient. For example, if you vared a file this way, the file is read twice: once for use by the editor, then again when vared retrieves the modified struct pm to write to it; there's currently no way mapfile can know that the value it's making is not going to be used, nor can it know when it will be called next, so there's no way of caching the value. Also, the file can potentially be copied any number of times by the handling in paramsubst(), though in general we can't really do a lot about this. I have a number of remarks and questions on parameter and related memory and efficiency issues, which I'll post separately (not today). A separate issue is the zmodload interface: I'd quite like it to change things so that you can pass arguments to the module you're loading to configure it, so that for example you can call the variable something other than mapfile. That's only a half-way street anyway, since you can't use multiple file mapping variables which would need some other interface to the module to arrange, probably beyond the scope of zmodload. But it might be useful anyway, although it's not that important. Does anybody use zmodload with multiple library arguments? It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