Cachable functions (was: Re: const, volatile, etc [was Re: #defines with parameters]

david wald wald-david at CS.YALE.EDU
Thu Dec 15 08:25:04 AEST 1988


In article <377 at aber-cs.UUCP> pcg at 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 at yale.UUCP
						       waldave at yalevm.bitnet
============================================================================



More information about the Comp.lang.c mailing list