3 ms·
I....do not grok article. I don't use function pointers and jump tables all that much, but I'm pretty sure you could add a function pointer argument to printNT
by qdog 12y ago
I....do not grok article. I don't use function pointers and jump tables all that much, but I'm pretty sure you could add a function pointer argument to printNTriples and replace the printf() with it and get somewhere if you really needed to get there. Starting to feel like I might be getting to the "Get off my damn lawn, kid!" part of my life.
- zvrba 12y ago> I'm pretty sure you could add a function pointer argument to printNTriples and replace the printf() You could, but the control is still driven by printNTriples. What if you had to break early, before generating all N triples? In this simple case, you could use a return value from the callback to decide whether to continue or not. In a more general case, you would you would encapsulate the state into a class (for example, the x,y,z,i locals from the original function would become instance memebers.)