<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=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class=""> > From: Chris Burrows <a href="mailto:chris@cfbsoftware.com" class="">chris@cfbsoftware.com</a> on Sun Feb 11 CET 2018</span></font><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class=""> ><br class=""></span></font><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class=""> > What I am really interested in is seeing some other existing</span></font><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class=""> > code examples where the advantage of having a local TYPE is</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class=""> > much more obvious and an alternative solution is not feasible.</span></font><br class=""><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="">It all boils down to the old question of what one should consider as</span></font></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">the “wall</span><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">” </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">to clients for information hiding and </span><span style="white-space: pre-wrap; font-family: monospace;" class="">abstraction purposes.</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""><br class=""></span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">Historically, it was ALGOL which had </span><span style="font-family: monospace; white-space: pre-wrap;" class="">introduced </span><span style="font-family: monospace; white-space: pre-wrap;" class="">the notions </span><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">of </span></font><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">limited</span></font></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">scopes (=limited visibility</span><span style="white-space: pre-wrap; font-family: monospace;" class="">) of identifiers </span><span style="white-space: pre-wrap; font-family: monospace;" class="">and of the </span><span style="white-space: pre-wrap; font-family: monospace;" class="">temporary </span><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">existence</span></font></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">(=limited lifetime) </span><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">of </span></font><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">objects such as </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">variables or procedures. The notion</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">of a </span><span style="font-family: monospace; white-space: pre-wrap;" class="">procedure is closely tied to that of allocation of its local variables.</span></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class=""><br class=""></span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">MODULA then added a second scoping structure, the module. It is similar</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">to a procedure in many ways, but unlike </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">a procedure, no allocation is</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">associated with a module, i.e. visibility </span><span style="white-space: pre-wrap; font-family: monospace;" class="">is not affected. Modules merely</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">constitute a “wall" around its local </span><span style="font-family: monospace; white-space: pre-wrap;" class="">objects which *may* be exported</span><span style="font-family: monospace; white-space: pre-wrap;" class="">.</span></div><div class=""><br class=""></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">The introduction of a second scoping structure (module) raised </span></font><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">a question:</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">what is (or should be) the actual “fence" to clients?</span></font></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""><br class=""></span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">The general consensus today is that it is the module, not the procedure.</span></div><div class=""><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">The idea to allow </span><span style="font-family: monospace; white-space: pre-wrap;" class="">l</span><span style="font-family: monospace; white-space: pre-wrap;" class="">ocal </span><span style="font-family: monospace; white-space: pre-wrap;" class="">(nested) procedures only adds some spice to this</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">debate, but </span><span style="font-family: monospace; white-space: pre-wrap;" class="">in </span><span style="font-family: monospace; white-space: pre-wrap;" class="">essence </span><span style="font-family: monospace; white-space: pre-wrap;" class="">information </span><span style="font-family: monospace; white-space: pre-wrap;" class="">hiding remains the business of modules.</span></div></div><div class=""><br class=""></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">*If* one accepts </span><span style="font-family: monospace; white-space: pre-wrap;" class="">that, </span><span style="font-family: monospace; white-space: pre-wrap;" class="">information hiding is preserved even when types used</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">only in a procedure are declared </span><span style="font-family: monospace; white-space: pre-wrap;" class="">globally within the module.</span></div><div class=""><br class=""></div></div></div></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">Now you can see one of the reasons why I dislike local procedures: now we</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">have N > 2 </span><span style="font-family: monospace; white-space: pre-wrap;" class="">scopes to deal with, when many programmers (or students) already</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">have difficulty </span><span style="font-family: monospace; white-space: pre-wrap;" class="">understanding </span><span style="font-family: monospace; white-space: pre-wrap;" class="">the difference between the two principal ones</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">(module, global procedure). This is also bad from a pedagogical perspective.</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""><br class=""></span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">AP</span></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="">PS: The paper which originally introduced the module concept in 1972 is still</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">one </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">of the best sources on this topic (David Parnas, “On the Criteria To Be</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">Used </span><span style="white-space: pre-wrap; font-family: monospace;" class="">in Decomposing Systems </span><span style="white-space: pre-wrap; font-family: monospace;" class="">into Modules”, </span><span style="white-space: pre-wrap; font-family: monospace;" class="">Comm. ACM 15, 12 Dec. 1972, 1053-1058)</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""><br class=""></span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""><br class=""></span></div></body></html>