Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!cernvax!chx400!bernina!neptune!inf.ethz.ch!brandis From: brandis@inf.ethz.ch (Marc Brandis) Newsgroups: comp.lang.modula2 Subject: Re: Standard Modula2 Message-ID: <21589@neptune.inf.ethz.ch> Date: 16 Jan 91 08:10:42 GMT References: Sender: news@neptune.inf.ethz.ch Reply-To: brandis@inf.ethz.ch (Marc Brandis) Organization: Departement Informatik, ETH, Zurich Lines: 27 In article Modula2 List writes: >>(according to Whirth)? Also if a pointer is unset will SIZE(ptr) return the >>size of what ptr points to? >If a pointer is "unset" (by that I assume you mean DEALLOCATEd), it >doesn't point to anything, therefore whatever SIZE might return would >have no meaning. You can of course call SIZE on the type of the >pointer and get the size that it would require. As far as I could >tell (and I didn't look that close) SIZE is not defined in the case >of a pointer being NIL or undefined, although it might be reasonable >to assume it would return 0 in the case of the former; what it >returns in the case of the former is entirely up to the compiler >writer and how the heap was implemented. SIZE is most often (in fact, in each compiler that I know of) implemented as the size of the type. That is, the compiler evaluates the type of the expression that stands inside the parentheses and then replaces the SIZE(expression) by the size of this type, which is a constant. This means especially that SIZE(expression) is never dependent on the actual value of the expression. In the above case, it means that it does not make any difference whether the pointer is NIL or not, the result is always the size of the type to which the pointer type is declared to point to. Marc-Michael Brandis Computer Systems Laboratory, ETH-Zentrum (Swiss Federal Institute of Technology) CH-8092 Zurich, Switzerland email: brandis@inf.ethz.ch