On 7/4/2024 8:05 PM, Lawrence D'Oliveiro wrote:
It’s called “Rust”.
If anything, I suspect may make sense to go a different direction:
Not to a bigger language, but to a more narrowly defined language.
(Ada, for example, has both arrays of arrays and multidimensional arrays
as distinct language features, using a(i)(j) to index the former and
a(i,j) to index the latter.)
On 7/4/2024 8:05 PM, Lawrence D'Oliveiro wrote:
It’s called “Rust”.
If anything, I suspect may make sense to go a different direction:
Not to a bigger language, but to a more narrowly defined language.
C also is the only language that is supposed to work on any kind of
processor ...
(Ada, for example, has both arrays of arrays and multidimensional arrays
as distinct language features, using a(i)(j) to index the former and
a(i,j) to index the latter.)
C assumes byte addressibility, but it doesn't assume that bytes are 8
bits.
The PDP-10 had 36-bit words and could operate on bit fields of any size
from 1 to 36 bits.
No, arrays are not pointers.
On many platforms, if _Alignof(type) is less than the word size, then a
C pointer to that type is implemented as the combination of the machine address of the correct word, combined with an offset within that word of
the first byte of that object.
BGB <cr88192@gmail.com> writes:
... in the 1D case, an array can be seen as functionally an
implicitly defined pointer ...
No, there is no implicitly defined pointer.
...
If you evaluate the expression `array_object` in most contexts, it's implicitly converted to a pointer *value*, pointing to the 0th element
of the array object. There is still no implicit pointer object.
On 06/07/2024 19:28, James Kuyper wrote:
... an expression that has type "array of type" is
converted to an expression with type "pointer to type" that points to
the initial element of the array object ..." (6.3.2.1p3).
This is really, really pedantic. Even gcc doesn't get it right in that
case, because if I try and compile this:
int a, b
a[b];
it says:
error: subscripted value is neither array nor pointer nor vector
'Subscripting' I think we can agree is the same thing as 'indexing':
what those funny square brackets do.
Lawrence D'Oliveiro <ldo@nz.invalid> writes:
On Fri, 05 Jul 2024 11:46:38 -0700, Keith Thompson wrote:
No, arrays are not pointers.
Except array indexing is designed to be indistinguishable from pointer
arithmetic.
No, arrays are not pointers.
On 7/9/24 20:57, Lawrence D'Oliveiro wrote:
On Sat, 6 Jul 2024 21:34:29 -0400, James Kuyper wrote:
On many platforms, if _Alignof(type) is less than the word size, then
a C pointer to that type is implemented as the combination of the
machine address of the correct word, combined with an offset within
that word of the first byte of that object.
Which is a terrific idea, except it cannot be carried to its logical
conclusion (addressing of arbitrarily-aligned dynamically-defined
bitfields) because of the requirement in the C spec that the size of a
“byte” be at least 8 bits.
I will grant you that I failed to mention the fact that this is a
feasible way of implementing C only on platforms with a word size of 16
bits or longer.
On 18/07/2024 15:00, Bart wrote:
On 18/07/2024 13:41, David Brown wrote:
You are trying to be too smart here, IMHO - the compiler's job is to
let the programmer be smart. It's always nice to have optimisations,
but not at the expense of correctness.
That's an odd remark from a devotee of gcc. Your usual attitude is to
let the programmer write code in the most natural manner, and let a
smart optimising compiler sort it out.
Touché :-)
Compilers can get smarter once you have them simple and correct. /Too/
smart - generating efficient but sometimes incorrect code - is not helpful.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (2 / 14) |
Uptime: | 148:49:56 |
Calls: | 10,383 |
Calls today: | 8 |
Files: | 14,054 |
D/L today: |
2 files (1,861K bytes) |
Messages: | 6,417,760 |