<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 Thu Oct 5 17:25:20 CEST 2017 Jörg wrote (slightly adapted by AP):</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="">> NW allows assignment of different ARRAY types only in case of</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">> open arrays. </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">This is reasonable as the formal parameter accepts</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">> different types.</span></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">></span></font></div><div class=""><font face="monospace" class="">>  1  <span style="white-space: pre-wrap;" class="">PROCEDURE Test(VAR open: ARRAY OF CHAR);</span></font></div><div class=""><font face="monospace" class="">>  2    <span style="white-space: pre-wrap;" class="">VAR local: ARRAY 17 OF CHAR;</span><br class=""><span style="white-space: pre-wrap;" class="">>  3  BEGIN</span><br class=""><span style="white-space: pre-wrap;" class="">>  4    local := open (* exception allowed by report*)</span><br class=""><span style="white-space: pre-wrap;" class="">>  5    open := local (* currently not allowed by report*)</span><br class=""><span style="white-space: pre-wrap;" class="">>  6  END Test;</span><br class="">><br class=""><br class=""></font></div></div><div class=""><font face="monospace" style="white-space: pre-wrap;" class="">It is my impression that the majority of participants in this forum</font></div><div class=""><font face="monospace" style="white-space: pre-wrap;" class="">seems to converge on </font><span style="white-space: pre-wrap; font-family: monospace;" class="">wanting only </span><span style="white-space: pre-wrap; font-family: monospace;" class="">name equivalence for </span><span style="white-space: pre-wrap; font-family: monospace;" class="">arrays</span><font face="monospace" style="white-space: pre-wrap;" class="">, but</font></div><div class=""><font face="monospace" style="white-space: pre-wrap;" class="">not structural equivalence - *</font><font face="monospace" style="white-space: pre-wrap;" class="">so long as*</font><span style="font-family: monospace; white-space: pre-wrap;" class=""> the language </span><span style="white-space: pre-wrap; font-family: monospace;" class="">report is 100%</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">unambiguous in this regard and </span><span style="white-space: pre-wrap; font-family: monospace;" class="">the type </span><span style="white-space: pre-wrap; font-family: monospace;" class="">rules outlined </span><span style="white-space: pre-wrap; font-family: monospace;" class="">in the report</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">also exactly </span><span style="font-family: monospace; white-space: pre-wrap;" class="">match </span><span style="font-family: monospace; white-space: pre-wrap;" class="">the </span><span style="font-family: monospace; white-space: pre-wrap;" class="">implementation. In short, one simply </span><span style="font-family: monospace; white-space: pre-wrap;" class="">just </span><span style="font-family: monospace; white-space: pre-wrap;" class="">wants</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">to know what *exactly* is </span><span style="font-family: monospace; white-space: pre-wrap;" class="">allowed, </span><span style="font-family: monospace; white-space: pre-wrap;" class="">and which language features one </span><span style="font-family: monospace; white-space: pre-wrap;" class="">can</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">safely rely on, e.g. when doing an implementation.</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="">If this is the case, the question discussed here should be rather easy</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">to </span><span style="font-family: monospace; white-space: pre-wrap;" class="">address (namely: pick name equivalence, spell the rule out in the</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">report, and make the compiler implementation conform </span><span style="font-family: monospace; white-space: pre-wrap;" class="">with the rule).</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="">Such a decision </span><span style="font-family: monospace; white-space: pre-wrap;" class="">would leave us with the one remaining </span><span style="font-family: monospace; white-space: pre-wrap;" class="">question of</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">which </span><span style="white-space: pre-wrap; font-family: monospace;" class="">exceptions </span><span style="white-space: pre-wrap; font-family: monospace;" class="">should in fact be allowed for open arrays</span><span style="font-family: monospace; white-space: pre-wrap;" class="">. </span><span style="font-family: monospace; white-space: pre-wrap;" class="">Currently,</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">in an array </span><span style="font-family: monospace; white-space: pre-wrap;" class="">assignment only the source</span><span style="font-family: monospace; white-space: pre-wrap;" class=""> can </span><span style="font-family: monospace; white-space: pre-wrap;" class="">be an open </span><span style="white-space: pre-wrap; font-family: monospace;" class="">array (</span><span style="font-family: monospace; white-space: pre-wrap;" class="">line 4</span><span style="font-family: monospace; white-space: pre-wrap;" class="">),</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">but not the destination (line 5).</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="">PROPOSAL:</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="">For an array assignment destination := source, Oberon-07..</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) generally allows the source array to be equal or to be shorter</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   than the </span><span style="font-family: monospace; white-space: pre-wrap;" class="">destination </span><span style="font-family: monospace; white-space: pre-wrap;" class="">array, i.e. </span><span style="font-family: monospace; white-space: pre-wrap;" class="">even if no open arrays are</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   involved, </span><span style="font-family: monospace; white-space: pre-wrap;" class="">i.e. the length is </span><span style="font-family: monospace; white-space: pre-wrap;" class="">always taken from the source.</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) if open arrays are involved in an array assignment, allow either</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   the source or the destination, or both, </span><span style="font-family: monospace; white-space: pre-wrap;" class="">to </span><span style="font-family: monospace; white-space: pre-wrap;" class="">be open arrays.</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) Allow this for multi-dimensional arrays as well.</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="">RATIONALE:</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="">a) </span><span style="font-family: monospace; white-space: pre-wrap;" class="">In Oberon-07, only formal procedure parameters can be open</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   arrays. </span><span style="font-family: monospace; white-space: pre-wrap;" class="">Dynamic </span><span style="font-family: monospace; white-space: pre-wrap;" class="">array variables allocated using NEW(p, size)</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   are not </span><span style="font-family: monospace; white-space: pre-wrap;" class="">included </span><span style="font-family: monospace; white-space: pre-wrap;" class="">in the Oberon-07 language report.</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="">b) If an array is passed as an open array parameter to a procedure</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   or function procedure, </span><span style="font-family: monospace; white-space: pre-wrap;" class="">its length </span><span style="font-family: monospace; white-space: pre-wrap;" class="">is always </span><span style="font-family: monospace; white-space: pre-wrap;" class="">passed on the stack</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   alongside its address, </span><span style="font-family: monospace; white-space: pre-wrap;" class="">in </span><span style="font-family: monospace; white-space: pre-wrap;" class="">accordance </span><span style="font-family: monospace; white-space: pre-wrap;" class="">with</span><span style="font-family: monospace; white-space: pre-wrap;" class=""> code </span><span style="font-family: monospace; white-space: pre-wrap;" class="">pattern #10 on p.21</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   of section 12.2. </span><span style="font-family: monospace; white-space: pre-wrap;" class="">of </span><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">the book "Project Oberon (2013 Edition)”. </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">This</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">   makes length </span><span style="font-family: monospace; white-space: pre-wrap;" class="">checks easy to implement at run time (see point d.).</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="">c) If neither the source nor the destination array are open arrays,</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   then their </span><span style="font-family: monospace; white-space: pre-wrap;" class="">lengths are known at compile time. Hence, the check</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   </span><span style="font-family: monospace; white-space: pre-wrap;" class="">whether </span><span style="font-family: monospace; white-space: pre-wrap;" class="">length(source) <= length(destination) </span><span style="font-family: monospace; white-space: pre-wrap;" class="">can be </span><span style="font-family: monospace; white-space: pre-wrap;" class="">performed</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   b</span><span style="font-family: monospace; white-space: pre-wrap;" class="">y the compiler, </span><span style="font-family: monospace; white-space: pre-wrap;" class="">and no run-time length checks are necessary.</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="">d) If either the source or the destination array, or both, are open</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   array parameters, then </span><span style="font-family: monospace; white-space: pre-wrap;" class="">their lengths are available at runtime on</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   the stack </span><span style="font-family: monospace; white-space: pre-wrap;" class="">(see point a.). </span><span style="font-family: monospace; white-space: pre-wrap;" class="">In that case, the length </span><span style="font-family: monospace; white-space: pre-wrap;" class="">check</span><span style="font-family: monospace; white-space: pre-wrap;" class=""> needed</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   before the array assignment, </span><span style="font-family: monospace; white-space: pre-wrap;" class="">can and must </span><span style="font-family: monospace; white-space: pre-wrap;" class="">be performed </span><span style="font-family: monospace; white-space: pre-wrap;" class="">at run time.</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="">e) The rules are easy to implement.</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="">f) The resulting assignment rules for arrays would become natural,</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   therefore also easy to </span><span style="font-family: monospace; white-space: pre-wrap;" class="">understand and </span><span style="font-family: monospace; white-space: pre-wrap;" class="">communicate in the report</span><span style="font-family: monospace; white-space: pre-wrap;" class="">.</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="">g) It would settle this question once and for good, with no chance</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   of confusion whatsoever (if done and communicated well).</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="">h) As a consequence of such an exact semantic definition of not only</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   what </span><span style="font-family: monospace; white-space: pre-wrap;" class="">exactly *is* considered to be part of the language, but also</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   what is *not* </span><span style="font-family: monospace; white-space: pre-wrap;" class="">part of it (</span><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">“what is IN and what is OUT”), </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">any </span><span style="font-family: monospace; white-space: pre-wrap;" class="">compiler</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">   implementation that decides to go beyond that “minimal </span><span style="white-space: pre-wrap; font-family: monospace;" class="">rule set” now</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">  </span><span style="white-space: pre-wrap; font-family: monospace;" class=""> </span><span style="font-family: monospace; white-space: pre-wrap;" class="">automatically</span> <span style="white-space: pre-wrap; font-family: monospace;" class="">becomes</span> <span style="font-family: monospace; white-space: pre-wrap;" class="">identifiable as such, and </span><span style="white-space: pre-wrap; font-family: monospace;" class="">therefore can be</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">   labeled </span><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">as implementing an “extension” </span></font><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">to </span></font><span style="font-family: monospace; white-space: pre-wrap;" class="">the Oberon-07 </span><span style="font-family: monospace; white-space: pre-wrap;" class="">language -</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   e.g., </span><span style="font-family: monospace; white-space: pre-wrap;" class="">a compiler implementing </span><span style="font-family: monospace; white-space: pre-wrap;" class="">structural equivalence </span><span style="font-family: monospace; white-space: pre-wrap;" class="">for arrays.</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="">COMMENTS:</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="">A. C</span><span style="font-family: monospace; white-space: pre-wrap;" class="">urrently only one-dimensional </span><span style="font-family: monospace; white-space: pre-wrap;" class="">open </span><span style="white-space: pre-wrap; font-family: monospace;" class="">arrays are handled by the</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">   compiler. Is there any deeper reason for this, or is this</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">   merely an implementation restriction? It seems to me that</span></div><div class=""><span style="white-space: pre-wrap; font-family: monospace;" class="">   with the </span><span style="font-family: monospace; white-space: pre-wrap;" class="">rules proposed above, it should be easy to include</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   multi-</span><span style="font-family: monospace; white-space: pre-wrap;" class="">dimensional arrays. If not, one would need to either add</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   an </span><span style="font-family: monospace; white-space: pre-wrap;" class="">additional language rule that restricts this to one-dimensional</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   arrays, </span><span style="font-family: monospace; white-space: pre-wrap;" class="">or leave it undefined and make it an implementation</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">   restriction - I dislike both. To be investigated.</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="">B. Strings are of course to be addressed separately (not discussed</span></font></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class="">   here, but </span></font><span style="white-space: pre-wrap; font-family: monospace;" class="">easy to add, as discussed earlier in this thread).</span></div><div class=""><font face="monospace" class=""><span style="white-space: pre-wrap;" class=""><br class=""></span></font></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class="">Any thoughts?</span></div><div class=""><span style="font-family: monospace; white-space: pre-wrap;" class=""><br class=""></span></div><div class="">-AP</div></body></html>