RE: Can you use C function pointers like you'd use LISP lambda?by (Login ComputerGhost)R I don't know lisp, but I've used C. Nested functions aren't standard C++, but gcc does support them as an extension. I could not get your code to compile, but I've studied it a little and will venture a guess as to what is happening. Here is what I think is happening: There is only one foo function. In main, when you call compose, a pointer to that one foo function is returned. When you call twoplus (aka foo): by coincidence, the memory taken up by a and b (inside of compose) has not been changed from pointing to oneplus; so foo calls oneplus(oneplus(x)) agan. If you call compose again with another value, I don't think twoplus will work as intended anymore because the values at the memory that a and b (inside of compose) use will change. I'd try this to see if I am right or wrong. |
| Response Title | Author and Date |
| I did the tests like you said, and there is indeed only one function created | qbguy on Jul 6 |