<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
TInt/TWord proposal<BR>
<BR>
<BR>TInt needs to be a "complete" replacement for INTEGER and LONGINT.<BR> Plus overflow checking.<BR> Not just for the frontend, but also m3back.<BR><BR>
<BR>
TWord needs to be a "complete" replacement for Word and Long.<BR> Therefore not likely any overflow checking.<BR>
<BR> <BR>
But in reality you might need all four:<BR> signed with silent overflow<BR> signed with nonsilent overflow<BR> unsigned with silent overflow<BR> unsigned with nonsilent overflow<BR>
<BR>
<BR>You can provide silent overflow by computing the result<BR>and leaving it to the caller to ignore the BOOLEAN or not.<BR>
<BR>
<BR>However in practise I don't think I needed silent overflow at all.<BR>The only places I allow it, I think really I'm confusing TInt with TWord,<BR>because TWord doesn't provide the right interface.<BR>
<BR>
<BR>
Settle on bits or bytes for sizes.<BR>Enshrine it mostly in the public interface.<BR> It maybe already is, granted.<BR> But more so -- external users can construct the things.<BR>
<BR>
<BR>Operations with mixed sizes shall not be allowed. <=== *****<BR> Just as INTEGER, LONGINT, Word, Long don't allow.<BR>
<BR>
<BR>
There would be some conversion functions, granted.<BR>SignedTruncate, UnsignedTruncate, SignExtend, ZeroExtend.<BR>
<BR>
<BR>
Constants Zero, One, MOne, etc. shall probably be<BR>replaced with an array of 8 each, or maybe just<BR>1, 2, 4, 8 -- the number of bytes in the size.<BR>
<BR>
<BR>"M" for "minus" is the wrong term.<BR>It should N or Neg or Negative.<BR>
<BR> <BR>
Something like:<BR>
TYPE BitCount = [8, 16, 32, 64]; (* not legal, darn *)<BR>TYPE ByteCount = [1, 2, 4, 8]; (* also not legal, darn *)<BR>TYPE ByteCount = [1..8]; (* wasteful, darn *)<BR><BR>
CONST Invalid = Target.Int{-1,IntBytes{0,..}};<BR>
<BR>
CONST ZeroBytes = IntBytes{0,..};<BR>CONST OneBytes = IntBytes{1,0,..};<BR>CONST NegativeOneBytes = IntBytes{16_FF,..};<BR>CONST ThirtyTwoBytes = IntBytes{32,0,..};<BR>etc.<BR>
<BR>
CONST Zero = ARRAY ByteCount OF { Target.Int{1,ZeroBytes}, Target.Int{2,ZeroBytes}, Invalid, Target.Int{4,ZeroBytes}, Invalid, Invalid,<BR> Invalid, Target.Int{8,ZeroBytes}};<BR>
<BR>
CONST One = ARRAY ByteCount OF { Target.Int{1,OneBytes}, Target.Int{2,OneBytes}, Invalid, Target.Int{4,OneBytes}, Invalid, Invalid,<BR> Invalid, Target.Int{8,OneBytes}};<BR>
etc.<BR>
<BR> <BR>
TInt.Zero becomes replaced by, e.g. TInt.Zero[Target.Integer.bytes] or TInt.Zero[Target.Longint.bytes]<BR>
<BR>
<BR>MAYBE as a possible simplification to the user:<BR>
<BR>Introduce InternalTInt which is today's TInt and then:<BR>TInt implies Target.Integer.bytes<BR>TWord implies Target.Integer.bytes<BR>new TLongint implies Target.Longint.bytes<BR>new TLong implies Target.Longint.bytes<BR>
<BR>
<BR>I really thing the short name "Long" is bad.<BR>There is no indication of unsignedness in it.<BR>It should be ULong or UnsignedLong or LongWord.<BR>
<BR> <BR>
"Word" is to INTEGER as what is to LONGINT?<BR> I don't think Long is the answer.<BR>
I'll start another thread on this.<BR>
<BR>
<BR>
m3back maintains a stack of mixed types, but I think it works out ok.<BR>
<BR>
<BR>
All that being said, I think what is there works and isn't terrible<BR>
and we don't need to solve lots of problems here.<BR>
<BR>
<BR>
I do think the variable sizing is a bit of a problem though.<BR>
<BR>
<BR>
- Jay<BR><BR> </body>
</html>