<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="">> On Sun Oct 15 06:52:19 CEST 2017 Luca Boasso wrote:</span></font><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">><br class="">> Since we have a garbage collector, unlike the Astrobe</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">> system designed for microcontrollers, probably it is</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">> cleaner to implement dynamic arrays like in Oberon-2.</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">> I would rather pay the price of longer collection </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">cycles</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">> (that only happens if dynamic arrays are used) </span><span style="white-space: pre-wrap; font-family: monospace;" class="">than a</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">> longer prolog/epilog for each function that </span><span style="white-space: pre-wrap; font-family: monospace;" class="">you pay</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">> at every invocation even if the feature is </span><span style="white-space: pre-wrap; font-family: monospace;" class="">not used.</span></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">> Don't get me wrong, I like Chris's implementation</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">> very much.</span></font></div><div class=""><br class=""></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">If you want to keep the current Oberon-07 </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">procedure call</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">mechanism (i.e. with </span><span style="white-space: pre-wrap; font-family: monospace;" class="">no FP), than </span><span style="white-space: pre-wrap; font-family: monospace;" class="">implementing </span><span style="white-space: pre-wrap; font-family: monospace;" class="">dynamic</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">arrays in the Oberon-2 is what </span><span style="font-family: monospace; white-space: pre-wrap;" class="">you would need to do.</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="">And the Oberon-07 procedure </span></font><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">call mechanism is indeed</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">worth keeping! </span></font><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">It </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">has </span><span style="white-space: pre-wrap; font-family: monospace;" class="">been made </span><span style="font-family: monospace; white-space: pre-wrap;" class="">possible </span><span style="font-family: monospace; white-space: pre-wrap;" class="">(in the step</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">from Oberon </span><span style="font-family: monospace; white-space: pre-wrap;" class="">to </span><span style="font-family: monospace; white-space: pre-wrap;" class="">Oberon-07) </span><span style="font-family: monospace; white-space: pre-wrap;" class="">by several </span><span style="font-family: monospace; white-space: pre-wrap;" class="">key </span><span style="font-family: monospace; white-space: pre-wrap;" class="">decisions:</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="">1) First, </span><span style="font-family: monospace; white-space: pre-wrap;" class="">access </span><span style="font-family: monospace; white-space: pre-wrap;" class="">to intermediate </span><span style="font-family: monospace; white-space: pre-wrap;" class="">variables </span><span style="white-space: pre-wrap; font-family: monospace;" class="">has been</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class=""> eliminated </span><span style="white-space: pre-wrap; font-family: monospace;" class="">from </span><span style="white-space: pre-wrap; font-family: monospace;" class="">the language. </span><span style="white-space: pre-wrap; font-family: monospace;" class="">This </span><span style="font-family: monospace; white-space: pre-wrap;" class="">eliminated the</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""> need for a</span><span style="font-family: monospace; white-space: pre-wrap;" class=""> static </span><span style="font-family: monospace; white-space: pre-wrap;" class="">link (SL) in </span><span style="font-family: monospace; white-space: pre-wrap;" class="">implementations.</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="">2) Second, only objects </span><span style="font-family: monospace; white-space: pre-wrap;" class="">with </span><span style="font-family: monospace; white-space: pre-wrap;" class="">a </span><span style="font-family: monospace; white-space: pre-wrap;" class="">size </span><span style="font-family: monospace; white-space: pre-wrap;" class="">known </span><span style="font-family: monospace; white-space: pre-wrap;" class="">at compile-</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""> time </span><span style="font-family: monospace; white-space: pre-wrap;" class="">are ever allocated on the </span><span style="font-family: monospace; white-space: pre-wrap;" class="">stack. This eliminated</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""> the need for a dynamic link (DL) or </span><span style="font-family: monospace; white-space: pre-wrap;" class="">a frame pointer.</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""> Now, adjusting a single register (namely the SP)</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""> by an amount known at compile-time suffices.</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="">3) Third, </span><span style="font-family: monospace; white-space: pre-wrap;" class="">structured types (arrays and records) are</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""> always passed by reference, </span><span style="font-family: monospace; white-space: pre-wrap;" class="">regardless of </span><span style="white-space: pre-wrap; font-family: monospace;" class="">whether</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class=""> they are value- or VAR- parameters. This </span><span style="white-space: pre-wrap; font-family: monospace;" class="">makes </span><span style="font-family: monospace; white-space: pre-wrap;" class="">stack</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""> usage about as minimal as it gets, as no </span><span style="font-family: monospace; white-space: pre-wrap;" class="">copying </span><span style="font-family: monospace; white-space: pre-wrap;" class="">of</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""> structured parameters ever occurs </span><span style="font-family: monospace; white-space: pre-wrap;" class="">(the </span><span style="font-family: monospace; white-space: pre-wrap;" class="">implication</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""> is </span><span style="font-family: monospace; white-space: pre-wrap;" class="">that structure value-parameters are</span><span style="font-family: monospace; white-space: pre-wrap;" class=""> ready-only).</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="">In </span><span style="font-family: monospace; white-space: pre-wrap;" class="">addition, in the RISC processor, the return address</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">is placed </span><span style="font-family: monospace; white-space: pre-wrap;" class="">in a register (LNK) by the branch instruction,</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">and so </span><span style="font-family: monospace; white-space: pre-wrap;" class="">the call </span><span style="font-family: monospace; white-space: pre-wrap;" class="">only consists of a single BL instruction,</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">while all </span><span style="font-family: monospace; white-space: pre-wrap;" class="">the </span><span style="font-family: monospace; white-space: pre-wrap;" class="">rest is done in a single place, namely in</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">the </span><span style="font-family: monospace; white-space: pre-wrap;" class="">prolog/epilog </span><span style="font-family: monospace; white-space: pre-wrap;" class="">rather than before each call.</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="">Hence, procedure calls are optimally efficient in</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">Oberon-07. I’d </span></font><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">say it’s rather pristine. It</span></font><span style="font-family: monospace; white-space: pre-wrap;" class=""> also </span><span style="font-family: monospace; white-space: pre-wrap;" class="">kind</span></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">of marks the end point in </span></font><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">a long </span></font><span style="font-family: monospace; white-space: pre-wrap;" class="">history of </span><span style="font-family: monospace; white-space: pre-wrap;" class="">refining</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">the procedure call mechanisms starting with </span><span style="font-family: monospace; white-space: pre-wrap;" class="">the Euler/</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">Algol days and then in Pascal, Modula and Oberon. It</span></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">really doesn’t get much more (time and space) </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">efficient</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">than that. And you can build systems </span><span style="white-space: pre-wrap; font-family: monospace;" class="">with small stacks.</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""> </span></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">On the other hand, allocation of dynamic arrays via</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">NEW(ptr, size) was eliminated in </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">Oberon-07. But that</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">is another one of those </span><span style="white-space: pre-wrap; font-family: monospace;" class="">length discussions that were</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">held in the late 80s/</span><span style="white-space: pre-wrap; font-family: monospace;" class="">early 90s at ETH. Papers were</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">written on this.. But Oberon-2 has found a </span><span style="white-space: pre-wrap; font-family: monospace;" class="">satisfactory</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">solution. But it also requires some </span><span style="white-space: pre-wrap; font-family: monospace;" class="">extra effort, e.g.</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">for the garbage collector.</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class=""><br class=""></span></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">I was intrigued by Chris’s approach to local dynamic</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">arrays, because storage reclam</span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">ation is automatic.</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="">Perhaps there is no way to get THAT without having</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">to also introduce a FP and lengthen the prolog/epilog</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">of *each* procedure. </span></font><span style="font-family: monospace; white-space: pre-wrap;" class="">But the one who does </span><span style="white-space: pre-wrap; font-family: monospace;" class="">find a way</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">around this </span><span style="white-space: pre-wrap; font-family: monospace;" class="">probably deserves a price.. ;-)</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="">-AP </span></font></div></body></html>