|
![](/i/fill.gif) |
On 4/25/2012 1:07, Invisible wrote:
> C and C++ have function pointers. It's dubious whether functions are "first
> class", but certainly you can pass them as arguments.
Given that the only levels of context in C is "global" and "auto", one could
even argue that a function pointer in C is actually a closure, as it
succeeds in capturing every variable in the scope of the function. ;-)
> C# presumably allows /everything/.
Not sure what that means. You *can* create functions on the fly in C#, so
yeah, I don't think there's much you can't do with enough work.
> Java allows you to use the reflection API to create an object that
> represents a function method, and to invoke that method. Alternatively you
> can use anonymous inner classes. (The fact that this feature even /exists/
> tells you how badly Java programmers want anonymous functions.)
Anonymous inner classes aren't functions. They're classes you instantiate.
> Eiffel? Well, they have "delegates", which are sort-of the same thing.
I'm not sure what's "sort of" about them. You can create a new function,
create a delegate to it, assign it to a variable, send it over a network
connection, and invoke the function.
--
Darren New, San Diego CA, USA (PST)
"Oh no! We're out of code juice!"
"Don't panic. There's beans and filters
in the cabinet."
Post a reply to this message
|
![](/i/fill.gif) |