Thought about programming
-
I've thought about that, too. It's a little hard to use in certain cases, though -- for example if you want to pass a value directly to another function. I mainly wish for it when I have multiple ins and outs from a function (and some variables are in+out). Sometimes I can't tell which variables are which -- hence the "tuple" thing, because return values are always out. In general, I compensate for this by using pointers (not references) for all out variables (of course, I can't tell if a variable is in+out or just out). The end result looks like this: int a,b; FooBar( &a, &b ); See the "address of" operator? That tells me that it's an out variable. If you use references you simply can't tell. Are "a" and/or "b" input, output, or both? FooBar( a,b ); I've also considered the possibility of a different argument syntax. For example, forcing programmers to break arguments into separate input and output sections (where a,b are "in" and c,d are "out" variables): int a, b, c, d; MyFunc( a,b )( c,d ); That syntax doesn't address in+out variables. Some other variation might be useful for that (because I hesitate to add even more parenthesis). (e is in+out) MyFunc( a,b; e; c,d ); Kinda looks like a "for" statement, doesn't it? ------------------------------------------ "Isn't it funny how people say they'll never grow up to be their parents, then one day they look in the mirror and they're moving aircraft carriers into the Gulf region?" - The Onion
How about this:
(int, int)MyFunc(int x, int y)
{
if (x < y)
return x, y;
else
return y, x;
}int main()
{
int x, y;(x, y)=MyFunc(6, 10);
.
.
.
}Or maybe
MyFunc(int x, int y) returns (int, int)
{
if (x < y)
return x, y;
else
return y, x;
}int main()
{
int x, y;(x, y)=MyFunc(6, 10);
.
.
.
}Jamie Nordmeyer Portland, Oregon, USA