Peter Gerwinski wrote:
Is "Integer(n)" supposed to support bigger types than LongestInt?
No. Somebody else may implement that ... ;-)
Thinking about it, it might be better to implement long integers as a schema or object type (perhaps with PXSC operators?)...
BTW: Is there any information about schema types and/or PXSC available? I don't know more about them than I saw in some examples. If I know more about them, it could be relatively easy to implement them...
The following program writes 0. ("+" doesn't seem to work correctly with big integers at all, telling from the asm code.)
program x; var a:integer(128); begin a:=$FFFFFFFF; a:=a+1; writeln(integer(a)) end.
This is correct: "a + 1" gets the integer value $100000000 in this example; the cast to `Integer' yields an (uncatched)-: overflow and the correct value 0 for the lowest 32 bits.
The example was bad, but in fact a+1 did not get the correct value as the following programs shows (writes "0 0 0 0"). But obviously, it wasn't supposed to...
program x; var a:integer(128); b:record c,d,e,f:cardinal end absolute a; begin a:=$FFFFFFFF; a:=a+1; writeln(b.f,' ',b.e,' ',b.d,' ',b.c) end.
At least "=" seems to work with these types, which would make "Cardinal(128)" usable for ClassIDs (I hope)... :-)
Sorry to have it taken out again! ;-)
Then, we can use something like a record of 2 card64's (internally). Actually, thinking about it, it might even be better. If 64 bits are the "programmer ID" anyway, it could be easier to declare this once, and to declare only the other 64 bits (which is possible :-) for each class. And, when the "programmer ID" is declared (typically at the beginning of a unit), a base value for the "class ID" could perhaps also be given, so that the actually declared class IDs would be simple (small) numbers without the need of constants. I'm not sure about a good syntax for it, but I mean something like the following:
const MyProgrammerID=$12345678;
set base ID to MyProgrammerID,$0f000000
type x=object[1] ...
which would result in an actual class ID of $123456780f000001.
Unique and easy to type! :-)
But it would also be useful (e.g. for constants for the big integers when they're implemented) to be able to specify (arbitrarily) long integers to be filled into a data structure (array of word or so...), analogous to arbitrarily long sequenced of characters filled into an array (aka strings :-).
E.g.:
var x:array[1..10] of word;
begin x:=8932740732465987432659087423658294376597843265987432659786; {fill this number into x (according to endianness, "0-padded" for positive numbers, "F-padded" for negative ones)}
if x+430985234985790342857=2938576498734697856 then ... end.
Would this be possible to do? The latter instruction seems more difficult. "+" and "=" could be operators, implemented in Pascal. The requirement to the compiler would be to convert such numbers into an array (and a length value) automatically. Seems difficult, but since it's just like with strings, I hope it's possible...