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 : 16. Aug 2024, 00:29:32
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240815161923.408@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
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-08-15, Bart <
bc@freeuk.com> wrote:
On 15/08/2024 22:36, Tim Rentsch wrote:
I see. So your point is, if we ignore all the ways that the two
modes are different then they are exactly the same.
Brilliant deduction, Dr. Watson.
>
So your approach is to totally ignore all the ways that the two modes
are identical.
Almost any two different things have some attributes that are identical.
If we consider a bicycle and a fish, we can probably come up with common
attributes.
Passing pointers by value similar to call-by-reference, but also
different.
The program can calculate a bad pointer and pass that by value.
Call-by-reference implementations can take measures to ensure that
a a bad reference is not passed.
The function call syntax itself, for a by-reference parameter, requires
an expression that designates an object, and takes a reference to that
object implicitly. Inside the function, there is no visible pointer;
the by-reference argument appears to be an alias for the referenced
object. Since there is no pointer, the address cannot be incremented
or reassigned.
(In a language that has both pointers and call-by-reference, it may
be possible to calculate a bad pointer, dereference it and use the
resulting expression as a reference argument. Then the reference
will be bad: but the root cause is pointer misuse, not the
call-by-reference mechanism.)
It is mainly syntactic differences. Call-by-reference can be implemented
using pointers, which can happen in a very early compiler pass; the
first intermediate code can already be transformed to using pointers.
If your point of view is that pointers are what is "real under the
hood", then call-by-reference is just "syntactic sugar" for pointers.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca