Re: Safe pointer arithmetic and typecasts :D

From: Bruce Roberts (ber_at_bounceitattcanada.xnet)
Date: 03/31/04


Date: Wed, 31 Mar 2004 09:53:01 -0500


"Skybuck Flying" <nospam@hotmail.com> wrote in message
news:c4ds2v$4ag$1@news5.tilbu1.nb.home.nl...

> I always wondered how to do safe pointer aritmetic in delphi without
> overflow errors or warnings...

There is no really safe method of doing pointer arithmatic in any language.
But there really isn't a need to use pointers in Delphi unless one is
constructing trees and graphs. In which case pointer arithmatic is not
needed. If you want to index through a linear structure use the tools
available in Delphi. Namely arrays. In the case of text, use the long string
type. It can be indexed as a vector (array) so there is no need for pChar.
The advantage of using array references is that when bounds checking is
turned on the program is going to catch any invalid indexes.



Relevant Pages

  • Re: ruby programming best practice
    ... is there a way to find out these spots in my program, like a compiler do in Delphi/C. ... I will naturally assume arr is an array. ... In delphi, for example, such error is detected while compile, e.g.. ... I know Ruby works differently, but is there a way exists, like a normal compiler, or something like FxCop for the C# language? ...
    (comp.lang.ruby)
  • Re: Answer to why low and high are bad !
    ... of array it is. ... Parallel structure within the loop code: ... Perhaps Delphi is the only language _flexible_ enough to need those ...
    (alt.comp.lang.borland-delphi)
  • Re: Object Hash vs. object Array preference
    ... > JavaScript/JScript Object accepts CDATA literals as property name. ... or any _JS language_ reference for that matter. ... > Array index is unsigned 32 bit value ... efficient to always quote all parameters for the bracket property ...
    (comp.lang.javascript)
  • Re: "C vs java"
    ... The first obvious error is the confusion of implementations with the ... language proper, in the "compilation" row. ... The "array declarations" row doesn't show how to declare an array. ... realloc but also static declaration syntax. ...
    (comp.lang.c)
  • Re: "C vs java"
    ... The first obvious error is the confusion of implementations with the ... language proper, in the "compilation" row. ... The "array declarations" row doesn't show how to declare an array. ... realloc but also static declaration syntax. ...
    (comp.lang.c)