3 ms·
Cute, but functions pointers suit me just fine.
by snorkel 15y ago
Cute, but functions pointers suit me just fine.
- huhtenberg 15y agoAnonymous functions are very handy, and I think they should really be taken a step further. There's really no reason why it shouldn't be possible to pass an actual function body where a function pointer is required: int v[...]; qsort( v, ..., (a, b) { return *(int*)a - *(int*)b } ); Such usage would also have an added benefit of letting the compiler do the type inference for a, b and the return value and not needing to explicitly specify them in qsort() call.
- CamperBob 15y agoLocal functions would be a nice compromise between the unreadable glop that was posted and the need to declare an entirely separate function to execute localized actions.