Re: I suppose the idea of classes and inheritance is
- From: Rob Kennedy <me3@xxxxxxxxxxx>
- Date: Sat, 14 Oct 2006 13:09:17 -0500
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
.
- Follow-Ups:
- References:
- I suppose the idea of classes and inheritance is
- From: Genome
- Re: I suppose the idea of classes and inheritance is
- From: Maarten Wiltink
- Re: I suppose the idea of classes and inheritance is
- From: Genome
- Re: I suppose the idea of classes and inheritance is
- From: Jamie
- Re: I suppose the idea of classes and inheritance is
- From: Maarten Wiltink
- Re: I suppose the idea of classes and inheritance is
- From: Jamie
- Re: I suppose the idea of classes and inheritance is
- From: J French
- Re: I suppose the idea of classes and inheritance is
- From: Jamie
- Re: I suppose the idea of classes and inheritance is
- From: J French
- Re: I suppose the idea of classes and inheritance is
- From: Jamie
- Re: I suppose the idea of classes and inheritance is
- From: J French
- Re: I suppose the idea of classes and inheritance is
- From: Jamie
- I suppose the idea of classes and inheritance is
- Prev by Date: Re: I suppose the idea of classes and inheritance is
- Next by Date: Re: I suppose the idea of classes and inheritance is
- Previous by thread: Re: I suppose the idea of classes and inheritance is
- Next by thread: Re: I suppose the idea of classes and inheritance is
- Index(es):
Relevant Pages
|