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 4:20

#include <stdio.h>

int divr(int a, int b, int *rem) {
if (rem) *rem = a % b;
return a / b;
}

int main(int argc, const char *argv[]) {
int touhous = 5, men = 12, unsucked = 0;
int eachSucked = divr(men, touhous, &unsucked);
printf("Each of the %d touhous sucked %d cocks, leaving %d unsucked\n",
touhous, eachSucked, unsucked);
return 0;
}


So what's the problem?

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