From: Walt Brainerd <[log in to unmask]> Wrote:
...
>> I can see how this might be vaguely useful, but what a mess it makes
>> of the language. I'm just curious why pointers to zero-sized objects
>> is allowed at all. Is there a value I'm not seeing?
>
>I would say simply to avoid exceptions and inconsistencies (we haven't
>done it very well, however).
>
>P1 => array (1:n) ; P2 => array (1:n)
>
>I would expect these to be associated for any legal value of n
>(not become false just because n is 0, for example) and certainly
>would not want this to be legal or illegal depending on the value
>of n [any more than allocate (array(1:n)]. That's the whole
>reason to allow zero-sized arrays in the first place, I think.
Ok, I see your position. I don't find it compelling. There are a
number of places in the language where a construct becomes
illegal depending on the run-time value of a variable. Divide
when the denominator is zero, for example. Or square root
with a negative. Or, subscripting with an out of range subscript.
Is it the case that making zero-sized arrays illegal would have
made programming more difficult with respect to the above?
Or, is the problem merely that it would slightly complicate
implementation (how do you report the exception, that kind
of thing)?
I'm not criticizing (it's too late anyway). I avoid pointers as
much as possible, and this just seems to be another reason to
do so. I would really like to have a better understanding of
why things were done this way.
--
J. Giles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|