Waldek Hebisch wrote:
Well, FillChar is low-level, working on memory directly.
Low-level does not exclude error checking. The following:
var c : char ... fillchar(c, 2, ' ');
is wrong. It make sense to flag such things, as long as there is a way to write the correct cases. More precisely, IMHO it is acceptable to recect some versions as long as there is an acceptable alternative.
[...]
I am not sure if the effect would justify the effort, but in principle transfering:
filchar(x, l, c);
into something like
if sizeof(x) >= l then filchar_lowlevel(x, l, c) else RangeCheckError;
does not look very hard. Of course, for really low-level use we should add something like:
fillchar(Void(x), n, c);
to bypass the length check.
For built-in FillChar, Move, ... it might be possible, but as I wrote, one can write such routines on the user-level, using untyped parameters. (Whether or not that's good thing is beyond the point, talk about BP compatiblity.) And, of course, for such routines, the compiler generally can't know the actual size (it might even be computed at runtime from other values), so it can't do any checks.
So with your suggestion, we'd introduce "another kind of untyped parameters" plus, as you say, another step of low levels. I think it might be more confusing than helpful to users.
(Besides, I don't think it should be RangeCheckError, as range checking (in GPC so far, and in BP as well) is specifically about ordinal subranges. So we'd introduce another error condition as well, though that's probably the least problem.)
Frank