Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Jens Gustedt <Jens.Gustedt@loria.fr> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: References discussion |
| Date | 2011-07-02 09:51 +0200 |
| Organization | INRIA - CR Paris-Rocquencourt |
| Message-ID | <4E0ECE07.9030309@loria.fr> (permalink) |
| References | <iud02j$o39$1@speranza.aioe.org> <96up7uFfpqU1@mid.individual.net> <iudbq4$mm9$1@speranza.aioe.org> |
Am 28.06.2011 21:59, schrieb jacob navia: > Le 28/06/11 21:43, Ian Collins a écrit : >> foo( n++ ); // What is the resulting value of n? > I just do not see what is the problem but very probably it is my fault. The problem is that you can't get by any means close to the behavior of C++. In C++ many of the standard operators return lvalues where they return rvalues in C. For the example, instead of postfix ++ use foo(++n); This would compile in C++ (for foo taking a reference) and give the user about what (s)he expects, since (in C++) in contrast to n++ (which returns an rvalue) ++n evaluates to an lvalue that represents the same object as n. A simple rule that just implicitly creates lvalues from rvalues when passed to a function with references would have surprising effects for the programmer. Introducing references into C without discussing the types of all standard operators (in terms of rvalue or lvalue) and without discussing if functions would be allowed to return lvalues makes not much sense to me. Jens
Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread
References discussion jacob navia <jacob@spamsink.net> - 2011-06-28 18:38 +0200
Re: References discussion Ian Collins <ian-news@hotmail.com> - 2011-06-29 07:43 +1200
Re: References discussion jacob navia <jacob@spamsink.net> - 2011-06-28 21:59 +0200
Re: References discussion Jens Gustedt <Jens.Gustedt@loria.fr> - 2011-07-02 09:51 +0200
csiph-web