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:44

>>17
If black-and-white thinking is what thrives "in industry", then it's a shitty industry. No one is talking about total elimination of side effects, only about their clean, explicit isolation. If a function is performing side effects, fine - just declare it. If a function is performing only a transformation of some input value to a result value, then it should do just that, without being entangled with the whole program state. Because if having a 100 functions each of which could modify the program state is worse than having 10 of them and 90 functions which do their job without touching state.

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