Remix.run Logo
▲ pjmlp 2 hours ago

As shown in PL/I or NEWP, C could have done it both ways, checked and unchecked when really required, e.g. PREFIX(SUBSCRIPTRANGE), PREFIX(NOSUBSCRIPTRANGE).

Likewise regarding the storage for the length, if one is willing to go the way C went down a few years later, declare a pointer and make the array storage be pointer based, e.g. BASED(MY_ARRAY_PTR).

▲uecker 2 hours ago | parent [-]

Can you explain what you mean by "make the array storage be pointer based"?

▲pjmlp 5 minutes ago | parent [-]

In PL/I you can declare arrays with a length descriptor, thus allocating storage for the length, like in mostly safe systems languages.

Alternatively when allocating the array storage define its access to be pointer based.

This means no length descriptor will be stored alongside the array, and the access to array elements will be done via the given pointer.

It is up to the programmer not to mess up then.

Unfortunately C authors never added a way to do the former, given their experience with PL/I and Multics.

I am aware we are finally going into that direction.