<div dir="auto">So the thought experiment whether we can live without unsigned integers must be answered with a resounding "No".<div dir="auto"><br></div><div dir="auto">q. e. d. </div><div dir="auto"><br></div><div dir="auto">J. </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 2 May 2020, 08:23 Jörg, <<a href="mailto:joerg.straube@iaeth.ch">joerg.straube@iaeth.ch</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="DE-CH" link="#0563C1" vlink="#954F72"><div class="m_-6701106899482914740WordSection1"><p class="m_-6701106899482914740MsoPlainText"><span lang="EN-US">I think the root cause of this discussion is that the Oberon language does not clearly define the semantic of the H suffix.<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="EN-US">Let me try to explain what I mean. In my point of view we have to differentiate two conceptionally different layers. Let me call it<u></u><u></u></span></p><ul style="margin-top:0cm" type="disc"><li class="m_-6701106899482914740MsoPlainText" style="color:red"><span lang="EN-US">the red Oberon layer, as defined by the Oberon report.<u></u><u></u></span></li><li class="m_-6701106899482914740MsoPlainText"><span lang="EN-US" style="color:#0070c0">the blue implementation layer, as defined by the target CPU and the Oberon compiler.</span><span lang="EN-US"><u></u><u></u></span></li></ul><p class="m_-6701106899482914740MsoPlainText"><span lang="EN-US"><u></u> <u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="EN-US">In the red Oberon layer you might write<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="EN-US" style="color:red">CONST<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText" style="text-indent:18.0pt"><span lang="EN-US" style="color:red">Int = -1869574000;<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText" style="text-indent:18.0pt"><span lang="EN-US" style="color:red">Real = -5.702072E-29;<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="EN-US">Let’s assume the compiler has a 32bit CPU as target. The CPU represents INTEGERs as two’s complement (that’s quite common but not a given) then the red Oberon value <span style="color:red">-1869574000 </span>is represented by the blue 32bit pattern <span style="color:#0070c0">90909090</span>.<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="EN-US">If the floating point unit chooses to represent REALs as IEEE754 (that’s quite common but not a given) the red Oberon value <span style="color:red">-5.702072E-29 </span>is represented by the blue 32 bit pattern <span style="color:#0070c0">90909090.<u></u><u></u></span></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="EN-US"><u></u> <u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="EN-US">With these two layers in mind, the <b>H</b> suffix can have two totally different semantics<u></u><u></u></span></p><ol style="margin-top:0cm" start="1" type="a"><li class="m_-6701106899482914740MsoPlainText"><span lang="EN-US">is H purely working in the red Oberon layer and just be another notation to define an INTEGER?<br>Then, the decimal notation <span style="color:red">2425393296</span> and hex notation <span style="color:red">90909090H</span> are absolutely identical.<u></u><u></u></span></li><li class="m_-6701106899482914740MsoPlainText"><span lang="EN-US">Or does H do a type cast of the blue 32bit pattern <span style="color:#0070c0">90909090</span> into a red INTEGER value <span style="color:red">-1869574000</span>?<u></u><u></u></span></li></ol><p class="m_-6701106899482914740MsoPlainText"><span lang="EN-US"><u></u> <u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="EN-US">Looking at the Oberon-07 report the semantic of H looks more like a).<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="EN-US">NW’s Oberon-07 compiler behaves like b). Another hint that NW most probably had semantic b) in mind is the fact that a suffix R exists. 90909090R type casts the 32 bit pattern 90909090 into a REAL.<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="EN-US">The semantic of H should be better described in the Oberon report.<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="EN-US"><u></u> <u></u></span></p><p class="m_-6701106899482914740MsoPlainText">br<u></u><u></u></p><p class="m_-6701106899482914740MsoPlainText">Jörg<u></u><u></u></p><p class="m_-6701106899482914740MsoPlainText"><u></u> <u></u></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE">Am 01.05.20, 20:00 schrieb "Jörg" <<a href="mailto:joerg.straube@iaeth.ch" target="_blank" rel="noreferrer">joerg.straube@iaeth.ch</a>>:<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"><u></u> <u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> SHORT(90909090H) should generate an error, as 2.4 billion is big for a 32 bit integer.<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> Jörg<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > Am 01.05.2020 um 18:46 schrieb <a href="mailto:dave@brownsmeet.com" target="_blank" rel="noreferrer">dave@brownsmeet.com</a>:<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > Hi Oleg,<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > Re 1 - Personally I really dislike '90909090H - 100000000H' because it is more confusing to read than the alternatives.<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > Instead of SYSTEM.VAL(INTEGER, 90909090H) you may prefer SHORT(90909090H). It's a bit more concise, avoids the dependency on SYSTEM, and works whatever the 32 bit integer type is called (i.e. INTEGER or LONGINT).<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > (If you are adding support for LONGINT then you will almost certainly be adding support for SHORT() and LONG()).<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > ---<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > Re 2 - Yes, this fixes 32 bit hex literals. But it doesn't fix 16 or 8 bit hex literals. I think these should be considered too. It's also difficult to explain the use of the H vs L suffix - the description in the component pascal documentation is correct but very confusing.<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > ---<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > Re 3 - Yes, in this case (assuming you have added support for 64 bit integers) all arithmetic is 64 bit, and assignments to smaller int variables are simply clipped at the time they are stored. You don't need SHORT() or LONG().<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > If you do this I'd like to see a compilation option to do range checking at run time on every store to < 64 bits.<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > ---<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > Re 4 - Oberon already has casting under another name (type guard) for extended types - with the type name in brackets following the variable name. Maybe keep the syntax similar.<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > -- Dave.<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> On 2020-05-01 11:26, Oleg N. Cher wrote:<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> Dear Dave,<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> After all, the question: is the literal 90909090H considered 64-bit<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> unsigned or 32-bit signed? We have four solutions:<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> 1. Consider it as a 64-bit literal, by context. And if we need to<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> declare it as a 32-bit literal, we'll write it like this:<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> myint := 90909090H - 100000000H;<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> If we don't like writing code this way, we'll write it differently:<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> myint := SYSTEM.VAL(INTEGER, 90909090H);<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> , quite in the spirit of the Oberon paradigm. So, Artur, this is what<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> I suggest you do in your compiler.<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> 2. Consider it as a 32-bit literal. And for 64-bit use the postfix<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> modifier like 0FFFFFFFFL, as in Component Pascal. Ofront+ also<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> implements this option (in -C mode).<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> 3. Pretend that we have all integer literals of the same size. In this<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> case, all the hexadecimal digits allowed as a bitfield value of the<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> literal. This way is implemented in most Oberon-07 compilers, which is<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> justified by the lack of integer arithmetic of different bits in them.<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> (BYTE is a non-arithmeric type in Oberon-07, and its size does not<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> used in operations, always casted to INTEGER).<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> 4. Explicitly specifying the constant type, as there was in Turbo Pascal:<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> CONST MyConst = INTEGER(90909090H);<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> As in Active Oberon, Delphi and Turbo Pascal. But then it is necessary<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> to allow the same (note, non-system) casting in expressions - and<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> rushed.<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> I would suggest two ways. The non-system way:<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> CONST MyConst = 90909090H - 100000000H;<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> This will be our payment for the fact that there are no unsigned types<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> in Oberon. This is a simplification that I think is very useful, but<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> has a cost. So now we have all integer constants as signed numbers.<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> And the system way. Ofront+ supports:<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> myint := SYSTEM.VAL(INTEGER, 90909090H);<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> And in constants too:<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> CONST MyConst = SYSTEM.VAL(INTEGER, 90909090H);<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> The disadvantage here is the compatibility problem, because old<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> sources may contain literals that rely on the size of 32 bits. But<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> this is mitigated by the fact that Ofront+ supports 5 Oberon dialects,<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> >> and we can choose any of it at our discretion.<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > --<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <a href="mailto:Oberon@lists.inf.ethz.ch" target="_blank" rel="noreferrer">Oberon@lists.inf.ethz.ch</a> mailing list for ETH Oberon and related systems<u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> > <a href="https://lists.inf.ethz.ch/mailman/listinfo/oberon" target="_blank" rel="noreferrer">https://lists.inf.ethz.ch/mailman/listinfo/oberon</a><u></u><u></u></span></p><p class="m_-6701106899482914740MsoPlainText"><span lang="DE"> <u></u><u></u></span></p></div></div>
--<br>
<a href="mailto:Oberon@lists.inf.ethz.ch" target="_blank" rel="noreferrer">Oberon@lists.inf.ethz.ch</a> mailing list for ETH Oberon and related systems<br>
<a href="https://lists.inf.ethz.ch/mailman/listinfo/oberon" rel="noreferrer noreferrer" target="_blank">https://lists.inf.ethz.ch/mailman/listinfo/oberon</a><br>
</blockquote></div>