Path: utzoo!attcan!uunet!yale!wald-david From: wald-david@CS.YALE.EDU (david wald) Newsgroups: comp.lang.c Subject: Cachable functions (was: Re: const, volatile, etc [was Re: #defines with parameters] Message-ID: <45701@yale-celray.yale.UUCP> Date: 14 Dec 88 22:25:04 GMT References: <674@quintus.UUCP> <117@halcdc.UUCP> <468@auspex.UUCP> <9016@smoke.BRL.MIL> <10919@ulysses.homer.nj.att.com> <1450@micomvax.UUCP> <369@aber-cs.UUCP> <9143@smoke.BRL.MIL> <377@aber-cs.UUCP> Sender: root@yale.UUCP Reply-To: wald-david@CS.YALE.EDU (david wald) Distribution: eunet,world Organization: Yale University Computer Science Dept, New Haven CT 06520-2158 Lines: 26 In article <377@aber-cs.UUCP> pcg@cs.aber.ac.uk (Piercarlo Grandi) writes: >I would like to add a note (hope it does not start another stream of >misunderstanding, misrepresentation and abuse towards me :->) > > I would like to be able (maybe in C++ ?) to declare a procedure as > "register", to signify that the values it returns only depend on the > arguments and not on any globals, and thus it will always return the same > values given the same arguments. > > Apart from giving a very clever (that, as I said, I do not like) compiler > a good opportunity to do some caching of procedure's results, it would be > extremely useful to a mechanical (lint?) or human reader/verifier of the > code, as it would clearly document which procedures are functions and > which are generators/closures, an extremely important distinction. A nice idea. However, except for the argument of conserving keywords, I'm not sure that "register" is the right word (surely you don't intend to cache function variables in anything analagous to a PDP-11 register, do you?). Perhaps "cache" or "cachable"? It would certainly allow a useful optimization. ============================================================================ David Wald wald-david@yale.UUCP waldave@yalevm.bitnet ============================================================================