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]
Other format: [Raw text]

something that would be nice


Hi,

My name is Matt Wells and I'm the sole creator of the internet's soon-to-be
largest search engine, http://www.gigablast.com/ .

I have many functions that return an integer value, positive, zero or
negative so I can't really say "this function returns -1 and 
sets errno on error" because -1 is a legit value for my
function to return. Passing in a pointer to the extra value(s) I would like
returned is, in my view, sloppy and potentially confusing.

So my question is... would it be easy to make functions return multiple
values?

For example:

main () {
    int value , myerrno ;
    value , myerrno = myfunction ( a,b,c );
    // or even
    ( value , myerrno ) = myfunction ( a , b , c );
}
int , int myfunction ( int a , int b , int c ) {
    return a + b + c , 0;
    // or
    return ( a + b + c , 0 );
}

This is more in line with mathematics, too. A function can map
an N dimensional point to an M dimensional point.

What do you guys think about this?

Is it a common request?

Matt


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