Re: I suppose the idea of classes and inheritance is



Jamie wrote:
sorry to tell you, my R+ is normally on most of the time.
i only turn it off on finaliation of the app. but if it makes
you any happier, i included the {$R+} with no difference in
results.
my compiler is just happy with it.

Of course the compiler's happy with it. But try *running* the program.

now if you were to do that using a short string or a
array char it would then generate a range error.

No it wouldn't.

and by all rights, the original code should not fault anyways
since the compiler automaticly includes a #0 at the end of the
string which makes it part of the string.

No it doesn't. The string has a length associated with it, and the #0 that the RTL puts at the end of the buffer is *not* included in that count.

this is common practice
with many char array string functions, i just don't see why there
is such a problem here. ?

Well, since we're not talking about char array functions, what those functions do is irrelevant. We're talking about indexing into a string when range checking is enabled.

Have you really never noticed that range checking affects both the compile-time *and* run-time behavior of your code?

if you look at my code i pasted, i did not index past that point
even though the Length function would report 4, there is still a
fith charactor there if this is to be a dynamic string (RTL).

But that fifth character is not part of the string. Trying to access it will generate an ERangeError exception. At run time. The same place all other exceptions occur.

and again, try that on a short or charactor array type string and yes,
it will detect a range problem if you index out side the known boundrie's of object at compile time.

Not if you use a variable or a function, as the two code examples in question have done. The compiler only checks constant expressions at compile time. The compiler is not sophisticated enough to do any more analysis than that. Everything else is deferred until run time.

--
Rob
.



Relevant Pages

  • Re: Delimited String to Array
    ... The casting is not required, and neither is the parsing of the string ... to make explicit what the compiler does implicitly: ... new char array, then loading it with the first character of a string. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Performance/efficiency question
    ... Discussion with Neal Gafter (author of the Sun compiler) reveals that the ... "Jim Sculley" wrote in message ... I know String buffers are better for dynamic Strings, ... >>> Concatenation of compile time constant String literals occurs at ...
    (comp.lang.java.programmer)
  • Re: Just a bit of silliness
    ... The format string need not be ... a compiler could recognize "%?" ... format string *is* known at compile time. ...
    (comp.lang.c)
  • Re: Just a bit of silliness
    ... The format string need not be ... a compiler could recognize "%?" ... format string *is* known at compile time. ...
    (comp.lang.c)
  • Re: How is strlen implemented?
    ... >>>that strlen can still return the number of characters of a char array. ... >> Your compiler is either not standard compilant, ... Of course, if the string were zero length, then.... ... CLC FAQ ...
    (comp.lang.c)