Re: A doubly linked-list in C
- From: Han from China <autistic-pedantry@xxxxxxxxxxx>
- Date: Mon, 20 Apr 2009 08:58:49 -0600 (MDT)
Kaz Kylheku wrote:
Both views are simultaneously correct.
I agree. I think both views are reconciled by the technical distinction
between "pass *by* reference" and "pass *a* reference".
C never passes *by* reference (always *by* value). Yet in C you can pass
*a* reference.
It appears that the standard has been crafted with that distinction
("provides *a* reference" from what you cited).
It's also a distinction that appears in what I believe to be one of the
best programming-language texts around, _Programming Language Pragmatics_,
2nd edition, by Michael L. Scott.
On pg. 419, we see "Parameters in C are always passed by value, though the
effect for arrays is unusual: because of the interoperability of arrays
and pointers in C (Section 7.7.1), what is passed by value is a pointer;
changes to array elements accessed through this pointer are visible to the
caller."
(Scott uses the "actual parameter" vs. "formal parameter" terminology.
"Pass by value" and "pass by reference" are "parameter modes".)
On pg. 421, we see "One traditional problem with parameter modes---and
with the READONLY mode in particular---is that they tend to confuse the
key pragmatic issue (does the implementation pass a value or a reference?)
with two semantic issues: is the callee allowed to change the formal
parameter and, if so, will the changes be reflected in the actual
parameter? C keeps the pragmatic issue separate, by forcing the programmer
to pass references explicitly with pointers."
Yours,
Han from China
--
"Only entropy comes easy." -- Anton Chekhov
.
- References:
- Re: A doubly linked-list in C
- From: Kaz Kylheku
- Re: A doubly linked-list in C
- Prev by Date: Re: Return value of assignment operator
- Next by Date: Re: Return value of assignment operator
- Previous by thread: Re: A doubly linked-list in C
- Next by thread: Re: A doubly linked-list in C
- Index(es):
Relevant Pages
|