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

Hans-Peter Diettrich DrDiettrich1 at aol.com
Wed Dec 21 12:09:35 CET 2011


Skybuck Flying schrieb:

> ^ All of these examples are quite bad in the following way:
> 
> They become very static, which makes it pretty much impossible to change
> their range at runtime.

That's by design.

> These types are pretty much a left over from the days of turbo pascal, and
> is a reason why people switched to C, where arrays where dynamic in
> range/size.

C arrays are emulated by pointer operations, i.e. p[i] is equivalent to 
(p+i)*, with no chance left for range checks.

Delphi has added dynamic arrays, with range checks possible at runtime.


> The succ/pred functions are also pretty useless and dangerous.

Depends on proper implementation (with wrap-around).

DoDi



More information about the fpc-devel mailing list