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 10:18 -0800 |
| Organization | None to speak of |
| Message-ID | <lnobhsilu6.fsf@nuthaus.mib.org> (permalink) |
| References | <503FC37F.8050701@animats.com> <be6d64cd-2553-48e7-99b4-c0742b611119@googlegroups.com> <k44qnl$k3t$1@dont-email.me> <kan97e$h4n$1@dont-email.me> |
Shao Miller <sha0.miller@gmail.com> writes:
> On August 30th, 2012, at 12:23:29, John Nagle published:
>> Safe arrays and pointers for C through compatible additions to the language
>
> Some feed-back, if you care:
>
> I don't really care for importing references from C++11. C has long
> passed by value (with the exception of arrays [which itself has an
> exception in C89/C90]).
Strictly speaking, arrays are not an exception to the C rule that
function arguments are passed by value. Given
int arr[N];
func(arr);
an array is not being passed as an argument; rather, a pointer is
being passed (by value, of course). The implicit conversion of
the array expression to a pointer is unrelated to the fact that
it appears in a function call; the same conversion happens in
most contexts.
[...]
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 */
--
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 | Next 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