tags:

views:

55

answers:

4

Is there any difference between a calling of a function and invoking of a function?

+5  A: 

No, it's just a different name for the same thing.

Ferdinand Beyer
yup.. both represent the same thing
Ajay
A: 

I'm not sure what do you realy want to hear but..

In Java you can invoke function using reflection. You need to do something like this:

MyClass mc = new MyClass ();

mc.getClass ().getDeclaredMethods () [0].invoke ();

You can read this article about reflection.

Roman
So? You can "call" a function using reflection too. Its the same thing.
Stephen C
+1  A: 

The difference between call and invoke is not defined. To me(!) :

Calling means that I explicitly call the function in my code

Java example

object.method(arg1, arg2);

Erlang example

fun(Arg1, Arg2).

Invoking means that I have some sort of reference to a function (name, pointer, etc.), and ask a mechanism to call that function for me (passing the reference I have)

Jave example

method m = Class.forName("myClass").getMethod("method", new Class[] {Integer.TYPE, Integer.TYPE});
m.invoke(new Object[] {10, 20});

Erlang example

erlang:apply(mymodule, fun, [Arg1, Arg2]).
Zed
A: 

There are no functions in Java, only methods which are either attached to a class (static methods) or class instances.

In the old, non-OO languages, people used the term "call". When OO became all the hype, new names were invented and people said "we call a function" but "we invoke a method".

Aaron Digulla
Actually, they said "send a message".
Jörg W Mittag
Haven't seen that anywhere outside Objective C. When I learned C++, it was "invoke method".
Aaron Digulla
It has been used in Smalltalk *at least* since 1972. It is also used in Self, Newspeak, Io, Ioke, Ruby, Objective-C++, several Lisp OO systems, several Scheme OO systems.
Jörg W Mittag