<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span class="" style="font-family: monospace; white-space: pre-wrap;"> > Wirth tries very hard to avoid so called "type explosion”.</span><div class=""><span class="" style="font-family: monospace; white-space: pre-wrap;"> > Therefore, he rather declares a single record with very</span></div><div class=""><span class="" style="font-family: monospace; white-space: pre-wrap;"> > generally usable fields than a hierarchy of record types.</span></div><div class=""><span class="" style="font-family: monospace; white-space: pre-wrap;"> > And fewer type declaration in total also means fewer local ones.
For the compiler, the rationale for the decision to use such</span></div><div class=""><span class="" style="font-family: monospace; white-space: pre-wrap;">multi-purpose fields is explained in ch 12.3.1 on p.29 of:</span></div><div class=""><span class="" style="white-space: pre-wrap;"><br class=""></span></div><div class=""><span class="" style="white-space: pre-wrap;"><font face="monospace" class=""><a href="http://www.inf.ethz.ch/personal/wirth/ProjectOberon/PO.Applications.pdf" class="">www.inf.ethz.ch/personal/wirth/ProjectOberon/PO.Applications.pdf</a></font></span></div><div class=""><span class="" style="white-space: pre-wrap;"><font face="monospace" class=""><br class=""></font></span></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">But at least for the compiler, there is another reason for using</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">the rather compressed representation using multi-purpose fields:</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">to </span></font><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">minimize memory usage! For example, the </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">length of record type</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">ORB.Object is 56 bytes, to which procedure NEW</span><span style="white-space: pre-wrap; font-family: monospace;" class=""> will add 8 bytes</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">(for the type tag and the mark field) for a </span><span style="white-space: pre-wrap; font-family: monospace;" class="">total of 64 bytes.</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class=""><br class=""></span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">If one adds even a single field to this one record, memory usage</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">would double to 128 bytes for *each* allocated heap record </span><span style="white-space: pre-wrap; font-family: monospace;" class="">(it’s </span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">how heap blocks are implemented in PO2013: 32, 64, 128, n*256).</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class=""><br class=""></span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">Given that even for small modules there are typically hundreds</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">of identifiers in the symbol table (mainly because of imports),</span></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">it’s easy to increase heap usage by a few hundred KB, depending</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">on the size of the modules being compiled.</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class=""><br class=""></span></font></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">And THAT makes a big difference on a machine with only 1 MB</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">of memory (as used by PO2013) and a heap size of 415KB.</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class=""><br class=""></span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">I once did a small </span><span style="font-family: monospace; white-space: pre-wrap;" class="">experiment and found that it can easily</span></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">break the compiler on more than one occasion.</span></font></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""><br class=""></span></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">BUT: Such implementation considerations - which in addition</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">are completely irrelevant on machines with larger memories -</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">don’t belong </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">to a discussion about programming styles. But</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">historically, such considerations were important - as everyone</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">who has worked on machines such as the PDP-11 will remember :-)</span></div><div class=""><span class="" style="font-family: monospace; white-space: pre-wrap;"> </span></div></body></html>