Sujet : Re: on call by reference
De : alicetrillianosako (at) *nospam* gmail.com (Schol-R-LEA)
Groupes : comp.lang.schemeDate : 21. Mar 2024, 03:00:20
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <utg0r4$1qdpg$1@dont-email.me>
References : 1 2 3
User-Agent : Mozilla Thunderbird
Lawrence D'Oliveiro:
On Wed, 20 Mar 2024 10:57:18 -0400, Schol-R-LEA wrote:
Languages such as C and C++ are interesting in this regard, as they have
only call-by-value semantics, but also support passing explicit
pointers, which allows them to simulate call-by-reference semantics by
the passing of explicit pointers.
C++ allows “references”, where the “pointer” part is no longer explicit.
E.g.
ResType Func
(
ArgType & Arg
)
{
...
} /*Func*/
But of course this is not tied to function arguments at all, and can be
used elsewhere, e.g.
int A;
int & const B = A;
Now any assignment to “B” actually changes the value of “A”.
I had forgotten about C++ opaque references. Thank you for pointing that out.