Path: news.daimi.aau.dk!news.uni-c.dk!nntp-oslo.UNINETT.no!nntp-trd.UNINETT.no!nntp.uib.no!torget.bgnett.no!aage.priv.no!Norway.EU.net!EU.net!main.Germany.EU.net!fu-berlin.de!zrz.TU-Berlin.DE!news From: Kai Petzke Newsgroups: comp.lang.beta Subject: Re: [Q] Unique names Date: Fri, 06 Sep 1996 23:10:57 +0200 Organization: Technical University Berlin, Germany Lines: 47 Message-ID: <32309361.6E8349A4@marie.physik.tu-berlin.de> References: NNTP-Posting-Host: dial1-89.zrz.tu-berlin.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 2.02 (X11; I; Linux 2.0.0 i586) Chris Ranzau Hansen wrote: > > Hello, > > I'm building a prototype of a persistent store. I need some way to > create unique names for the objects to be saved. At the moment I'm > using the pattern time. The problem is that the result only changes > once every second. I'm thinking of adding a counter so that I can > create more than one unique name per sec. When you have a persistent store, why not put a single object there, that represents a counter, that yields a different serial number each time, it is accessed, eg: counter: (# state: @integer get: IntegerValue (# do state+1->state->value #); init: (# do 0->state #); #); When you first create the persistent store, you do something like: ps: ^persistentstore; count: ^counter; do &persistentstore[]->ps[]; 'store'->ps.create; &counter[]->count[]; count.init; (count[], 'counter')->ps.put; When you later access the persistent store, use: ps: ^persistentstore; count: ^counter; do &persistentstore[]->ps[]; 'store'->ps.openWrite; ('counter',counter##)->ps.get->count[]; The `checkpoint' and `close' routine of the persistentstore will automatically ensure, that the updated counter value is written back into the persistentstore, if required. -- Kai wpp@marie.physik.tu-berlin.de