This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Named Return Value Extension Proposal


One more thought...

> Date: Mon, 22 Mar 1999 13:07:13 -0800
> From: "E. Robert Tisdale" <edwin@netwood.net>
> To: egcs@egcs.cygnus.com

> X       g0(X x) {
>   cerr << "The copy constructor may be called for g0(X)." << endl;
>   return x;
>   }

> The current extension is very old now and it seems unlikely to me
> that it will ever be adopted as part of the ANSI C++ standard.

Right.

> It solves the problem that the egcs compiler has with function X f1(int)
> but the function definition is entirely incompatible with ANSI C++

Yes.

> and it cannot solve the problem that the compiler has with function
> X g0(X).

Why not?

X g0(X x) return x(x) {
  cerr << "The copy constructor may be called for g0(X)." << endl;
  return x;
}
  
If this doesn't scope this way now, I don't see it as a problem to fix
it so that it does, and so that the semantics of it just work the way
you expect.

> Of course, the current named value extension must be retained for
> backward compatibility but I propose a simple extension which
> permits the C++ programmer to insert the `return' keyword between
> the type and the name in a declaration to identify the name as a
> reference to the return value as shown below:

Your proposal is `better' than the original Name Value extension.  If
you proposed it 9 years ago, I would have voted that we do it instead
of the one that is in g++ now.  Now it is too late.  :-(

Because your proposal doesn't appear to bring anything new to the
table (stuff the existing extension already does), except for a
slightly more ANSI C++ feel to it.  I don't feel this slightly better
syntax is enough to want me to support the addition of an alternate
spelling of a preexisting hack.

Maybe someone will key off your pain, and devise a way to put in the
elision code that will `solve' this problem...  Make a great project
for someone that wants to play.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]