[fpc-devel] Re: Limitations of static "ranged" integer types and succ/pred, and dynamic solution.

Skybuck Flying skybuck2000 at hotmail.com
Tue Dec 20 07:57:08 CET 2011


Actually "wrap back" is probably not the correct behaviour for succ/pred.

So it should probably not "wrap back".

Instead it could give an out of range error message.

However at least Low and High should be able to be used on the dynamic range 
type, so that these limits can dynamically be acquired with those two 
functions.

This could help...

The user can then modify code from static to dynamic with minimal changes:

if Index = High(DynamicRangeType) then
begin
Index := Low(DynamicRangeType);
end;

To implement the range of the dynamic range type perhaps the following could 
be used:

SetLow( DynamicRangeType, 5000 );
SetHigh( DynamicRangeType, 6000 );

An oo version could also look like;

DynamicRangeType.SetLow( 5000 );
DynamicRangeType.SetHigh( 6000 );

Bye,
  Skybuck. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20111220/1d08c22d/attachment.html>


More information about the fpc-devel mailing list