From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uflorida!gatech!hubcap!wtwolfe From: wtwolfe@hubcap.UUCP (Bill Wolfe) Newsgroups: comp.lang.ada Subject: Re: Garbage Collection Message-ID: <3951@hubcap.UUCP> Date: 20 Dec 88 19:34:10 GMT References: <65713@ti-csl.CSNET> <3918@hubcap.UUCP> <65914@ti-csl.CSNET> Organization: Clemson University, Clemson, SC List-Id: In article <65914@ti-csl.CSNET>, gateley@m2.csc.ti.com (John Gateley) writes: > >> [I say infinite precision arithmetic is a good example of why GC is needed > >> sometimes]. > > > > The deallocation of every object in the local environment is > > performed as an automatic service when a procedure, function, > > or local block is exited. This is not garbage collection, > > because the programmer has implicitly directed that the > > destruction be performed. > > But, integers are not always deallocated. They may be returned as the > result of a function, assigned to global variables, placed in the > heap as parts of other data objects etc. What we are (presumably) discussing here is the space management applying to literals and/or anonymous values of some arbitrary type. During compilation, the compiler will evaluate each literal as an anonymous value of the appropriate type. Anonymous values differ from named values only in that the programmer cannot explicitly refer to them by name. Typically, literals are used in the construction of anonymous expressions which will ultimately serve as a value to be assigned. They are then being supplied as "in" parameters, and we have already discussed the proper method by which compilers should handle anonymous values passed as "in" parameters: they should be passed by handoff; since no external name exists, there is no need to set any external object to "undefined". Since anonymous values cannot simply exist in mid-air, and must always be consumed in the course of some statement, we know that they will always be consumed. By the rules of Ada, they cannot be supplied as "in out" or "out" parameters; hence, the mechanism described for handling anonymous values which are being passed as "in" parameters in a space-efficient manner serves to cover all cases, if we treat assignment as a procedure requiring an "in" parameter for the source value; otherwise, the extension to this case is straightforward. Thus, we have completely described the space management applicable to literals and other anonymous values, such that these values can be managed effectively without any need for recourse to garbage collection. All that is needed is a tighter definition of what happens to an anonymous value which is passed as an "in" parameter. Note that this analysis does not depend upon the amount of space which must be used to contain any given anonymous value. Bill Wolfe wtwolfe@hubcap.clemson.edu