Code is fine except for a minor detail: You have to use void *() for the type of callee in apply. You can't cast a function pointer to a void pointer. They don't even need to be the same size.
>>12 POSIX requires that this be possible (e.g. for dlsym) even though DA STANDARD itself does not. So in practice you can assume this will work.
Name:
Anonymous2014-04-26 9:34
>>19 POSIX sucks they even forced CHAR_BIT to be 8 and added many useless and bad made functions. they could atleast make dlsym work like this struct mydik { void (*f)(void); }; struct mydik *shit = dlsym (a, b)); mydik->f ();
char ** AINT COMPATIBLE WITH void **, YA CAST LIKE A FUKIN STAK BOI RETOID (void * CAN BE CONVERTED 2 A void ** WITHOUT VIOLATING DA STANDARD), CONVERTIN A POINTER 2 A FUNCTION TYPE 2 A POINTER 2 AN OBJECT TYPE HAS UNDEFINED BEHAVIOUR, CALLIN A int(const char *, ...) THROUGH A void *(*)(void *, ...) HAS UNDEFINED BEHAVIOUR, YA DONT KNO WAT abort DOES, YAINT HERD OF stderr, AND YAINT RED DA FUKIN STANDARD. DATS 4 DAM SURE.
Y DA FUK WUD U WANT TO DO FUNCTIONAL PROGRAMMING IN C ANYWAY, YA FUKIN DIKITA SADCOCK RETOID?
>>27 You can't be the original L. A. Calculus. He thought requiring CHAR_BIT == 8 was fine; punning function and data pointers is nothing next to that.
The only values that do not cause undefined behavior/implemetation defined behavior are 0, EXIT_SUCCESS and EXIT_FAILURE
Name:
Anonymous2014-04-27 10:48
>>27 hi lambda, this is offtopic but since I saw you I want to ask, what's the point of ptrdiff_t? why not size_t? it seems the same to me
Name:
Anonymous2014-04-27 10:56
>>32 ptrdiff_t has to be a signed integer. really_large_unsigned_integer - really_low_unsigned integer = overflow when stored in a signed integer of the same width In practice they're probably the same size on most platforms, since the only way you could get an overflow is by taking the difference of a pointer in kernel space (really high) and user space (really low), and that is not something that you'd ever need to do, but I see where da standed was going with it.
>>33 I though that ptrdiff_t was for subtracting pointers to the same object
Name:
Anonymous2014-04-27 11:36
>>34 You could also use it to compare two objects in a heap, two array indices, etc. Like I said, not a problem on typical 32/64 bit OSes, but imagine a microcontroller or DSP with a 24 or even 16-bit address space. You could easily have an array or heap on such a platform whose length will not fit into a pointer-sized signed integer.