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 : 12. Jul 2024, 13:14:40
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240712045301.394@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-07-12, bart <
bc@freeuk.com> wrote:
It's clearly not by value. It's apparently not by reference. You can't
get away with saying they are not passed, as clearly functions *can*
access array data via parameters.
Actually, you probably can get away with saying that it is "passed
by reference".
The formal term that doesn't apply is "call by reference"; that's what
C doesn't have.
"call by reference" emphasizes that the function call mechanism
provides the reference semantics for a formal parameter, not that some
arbitrary means of passage of the data has reference semantics.
The following also achieves "pass by reference":
int *global;
void child(void)
{
printf("%d\", global[13]);
}
void parent(void)
{
int array[20];
global = array;
child();
}
"pass" does not mean as a formal parameter.
For instance "message passing" (e.g. from one thread to
another) doesn't use formal parameters.
ISO C uses the "refer" word and derivatives thereof in connection
with pointers:
- "If an attempt is made to refer to an object defined with a
volatile-qualified type through use of an lvalue with
non-volatile-qualified type, the behavior is undefined".
The type from which a pointer is derived is called the "referenced
type":
- "The construction of a pointer type from a referenced type is
called ‘‘pointer type derivation’’ [C99]
A footnote in C99 used the word "dereferencing" to describe the
action of the unary * operator. This word is commonly used in
the C programming circles:
- "Among the invalid values for dereferencing a pointer by the
unary * operator are a null pointer, ..."
Another footnote in C99 uses "referenced" describing the relationship
of an pointer to the target object:
- "In other words, E depends on the value of P itself rather than
on the value of an object referenced indirectly through P.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca