Why not allow empty code blocks?

Marko Rauhamaa marko at pacujo.net
Tue Jul 26 03:56:14 EDT 2016


Gregory Ewing <greg.ewing at canterbury.ac.nz>:

> BartC wrote:
>> (Yes everyone uses T*a (pointer to T) instead of T(*a)[] (pointer to
>> array of T), because, thanks to how C mixes up deferencing and
>> indexing, the former can be accessed as a[i] instead of (*a)[i].
>>
>> But it's wrong, and leads to errors that the language can't detect.
>> Such as when a points to a single element not a block:
>
> This is an implementation issue, not a language issue. A sufficiently
> pedantic implementation could and would detect this kind of error at
> run time. Most implementations of C are not that pedantic, but you
> can't blame the language for that.

Well, one of the novelties in C was the intentional blurring of the
lines between arrays and sequences of elements in memory. The
notation:

   int a[3];

declares a as an array. However, the expression:

   a

does not produce an array; instead, it produces a pointer to the first
element of the array. Even:

   *&a

produces a pointer to the array's first element.


Marko



More information about the Python-list mailing list