Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.std.c |
| Subject | Re: Second draft, "Safe arrays and pointers for C" |
| Date | 2012-12-17 15:44 -0800 |
| Organization | None to speak of |
| Message-ID | <lntxrkgs6o.fsf@nuthaus.mib.org> (permalink) |
| References | (1 earlier) <be6d64cd-2553-48e7-99b4-c0742b611119@googlegroups.com> <k44qnl$k3t$1@dont-email.me> <kan97e$h4n$1@dont-email.me> <lnobhsilu6.fsf@nuthaus.mib.org> <kao9kc$9bb$1@dont-email.me> |
Shao Miller <sha0.miller@gmail.com> writes:
> On 12/17/2012 13:18, Keith Thompson wrote:
[...]
>> If C were to add some kind of pass-by-reference mechanism (other than
>> the existing pass-a-pointer-by-value), it might be useful to require
>> some distinguishing syntax on the call. For example, assuming the
>> addition of a "ref" keyword:
>>
>> void increment(ref int n) {
>> n ++;
>> }
>>
>> int x = 42;
>> /* increment(x); would be illegal */
>> increment(ref x);
>> /* now x == 43 */
>>
>
> While I agree that distinguishing syntax is desirable, I don't quite
> follow what the advantage of that particular example is, over pointers.
> (Of course, that mightn't've been a demonstration of an advantage, but
> simply of distinguishing syntax.)
It's not an advantage over pointers. It's an advantage over a
hypothetical pass-by-reference mechanism in which you can't tell,
by looking at a call, whether that call might modify the value of
the passed object.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.std.c | Previous | Next — Previous in thread | Find similar | Unroll thread
Second draft, "Safe arrays and pointers for C" John Nagle <nagle@animats.com> - 2012-08-30 12:48 -0700
Re: Second draft, "Safe arrays and pointers for C" pacman@kosh.dhis.org (Alan Curry) - 2012-08-31 22:17 +0000
Re: Second draft, "Safe arrays and pointers for C" John Nagle <nagle@animats.com> - 2012-08-31 17:26 -0700
Re: Second draft, "Safe arrays and pointers for C" Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2012-09-02 22:20 +0200
Re: Second draft, "Safe arrays and pointers for C" BGB <cr88192@hotmail.com> - 2012-09-03 10:55 -0500
Re: Second draft, "Safe arrays and pointers for C" Ike Naar <ike@iceland.freeshell.org> - 2012-09-03 16:39 +0000
Re: Second draft, "Safe arrays and pointers for C" BGB <cr88192@hotmail.com> - 2012-09-03 13:18 -0500
Re: Second draft, "Safe arrays and pointers for C" Jens Gustedt <jens.gustedt@loria.fr> - 2012-09-02 10:52 +0200
Re: Second draft, "Safe arrays and pointers for C" Per <per.mathisen@gmail.com> - 2012-09-28 06:49 -0700
Re: Second draft, "Safe arrays and pointers for C" John Nagle <nagle@animats.com> - 2012-09-28 11:36 -0700
Re: Second draft, "Safe arrays and pointers for C" Per <per.mathisen@gmail.com> - 2012-10-01 09:38 -0700
Re: Second draft, "Safe arrays and pointers for C" John Nagle <nagle@animats.com> - 2012-10-01 11:38 -0700
Re: Second draft, "Safe arrays and pointers for C" Shao Miller <sha0.miller@gmail.com> - 2012-12-17 09:11 -0500
Re: Second draft, "Safe arrays and pointers for C" Keith Thompson <kst-u@mib.org> - 2012-12-17 10:18 -0800
Re: Second draft, "Safe arrays and pointers for C" Shao Miller <sha0.miller@gmail.com> - 2012-12-17 18:24 -0500
Re: Second draft, "Safe arrays and pointers for C" Shao Miller <sha0.miller@gmail.com> - 2012-12-17 18:32 -0500
Re: Second draft, "Safe arrays and pointers for C" Keith Thompson <kst-u@mib.org> - 2012-12-17 15:44 -0800
csiph-web