Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Vector valued functions

Name: Anonymous 2014-06-12 23:50

Fuck lists and their overhead. I just want an extension to C that lets me return vectors. Not classes, not structs, and nothing involving preprocessor shit either. Something like:
<int, int> divr(int a, int b){
return < a / b, a % b >;
}
int main(int asdfasdf, char ** qwerqwe){
int touhous = 5, men = 12;
int eachSucked, unsucked;
<eachSucked, unsucked> = divr(men, touhous);
printf("Each of the %d touhous sucked %d cocks, and there were %d left unsucked", touhous, eachSucked, unsucked);
return 0;
}

which would compile to something simple, like:divr:
pop eax
pop ebx
push edx
xor edx, edx
idiv ebx
mov ebx, edx
pop edx
push ebx
push eax
ret
main:
touhous dd 5
men dd 12
eachSucked dd ?
unsucked dd ?
push touhous
push men
jmp divr
pop [eachSucked]
pop [unsucked]
;; blah blah blah, printf goes here

Isn't that much more elegant that a nasty list every time where things have to be inserted or initialized? Oh, and if you don't need a return value, <a,b,NULL, c> will compile the unneeded return value out, or at least discard the result.

Name: Anonymous 2014-06-13 11:23

>>8
Okay, in academia, you would be right. That is not theoretically the right way to express multiple return values, because side effects. In the industry, we actually run our code, and that means it has side effects.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List