Sujet : Re: technology discussion → does the world need a "new" C ?
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 10. Jul 2024, 07:05:14
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240709225811.135@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-07-10, James Kuyper <
jameskuyper@alumni.caltech.edu> wrote:
On 7/10/24 00:29, Lawrence D'Oliveiro wrote:
On Sat, 06 Jul 2024 15:38:14 -0700, Keith Thompson wrote:
...
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.
The OP said “pointer”, not “pointer object” or “pointer value”. Not sure
what hair you are trying to split here.
>
BGB referred to it as an "implicitly declared" pointer. You can declare
objects in C, but not values. An object has a location in addressable
memory where it is stored, a value need not exist anywhere in
addressable memory.
Right. But language features can use hidden variables.
In every implementation that I'm sufficiently familiar with, no memory
is set aside to store such a pointer object.
Even if the high level code generation declares such a hidden
variable, as in
int a[42];
int *$_ptr_a = a; // generated by compiler
// perhaps as an AST node rather than source
it could end up optimized away, like any other variable. Since the
variable is not visible to the program, no assignment to its value
will occur (unless the generated code does that). If no assignment
to it occurs, the optimization can just treat it as an alias for a,
and substitute every occurrence of $_ptr_a with a. (Raising the
question why the code generator didn't do that itself; it could
be a remnant from an ancient verson of the compiler that wasn't well
optimized. Then the optimizer came along, taking away the motivation
to fix something in the front that is taken care of by it.)
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca