This isn't necessarily any better, it just has more syntax support. However, it isn't equivalent to a function ptr, it's more equivalent to a structure with a fptr and associated data. A C++ function object or a C fptr pointing to a trampoline fn has exactly this functionality.
However, the functionality isn't the only thing. There are two notational conveniences that typically come along for the ride:
1) You can declare the function nested within another function. This is a necessary prerequisite to...
2) The associated structure is automatically created by the compiler based on what data the function uses in the surrounding context.
3) Just like the struct/fptr pair you might have created manually on the heap, you can return this function from another function with the data it captured coming along for the ride. That's generally were all the fun stuff happens :-)
To clarify this: See the recent "lambda" proposal for C++0x to see that same feature in the context of a Cish language, with the attendant modifications for manual memory management, stack based capture, etc.
However, the functionality isn't the only thing. There are two notational conveniences that typically come along for the ride:
1) You can declare the function nested within another function. This is a necessary prerequisite to...
2) The associated structure is automatically created by the compiler based on what data the function uses in the surrounding context.
3) Just like the struct/fptr pair you might have created manually on the heap, you can return this function from another function with the data it captured coming along for the ride. That's generally were all the fun stuff happens :-)
To clarify this: See the recent "lambda" proposal for C++0x to see that same feature in the context of a Cish language, with the attendant modifications for manual memory management, stack based capture, etc.