This is the mail archive of the egcs@egcs.cygnus.com mailing list for the EGCS project. See the EGCS home page for more information.


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

Re: naming results in C?


> Now, if I was able to declare mult_v like (this is impossible with
> the current C++ extension):
> 
>   mult_v(double f, int n, double v[]) return double res[n] 

Yes, this goes indeed beyond the C++ extension: You can't return
arrays, in particular not variable-sized ones, let alone with a named
return value.

So, with the named return value alone, your problem would not be
solved, right? I don't think returning arrays has been considered for
extensions. 

In C++, you don't have the need for it - you can wrap the array with
an object, and return the object which supports actively being copied.
In C, having to use out-parameters for this kind of application is
well-established. This gives the kind of control over memory that is
typical for C. If you want a more powerful language, use C++ :-)

That said: If you submit a patch that introduces all these extensions,
and fits into the usual criteria, it might get integrated into the
compiler.

Regards,
Martin