What is different of `call` and the function signature?

The first paramater of def defp defmacro and defmacrop are all named as call.
I think the counterpart of call in other language is function head or function signature,
So I want to know what is the diffenter between the call and function head/signatur?

1 Like

The call here is the function’s name (as you indicated). One difference between erlang/Elixir and many other languages is that the function signature is the combination of the name and the arity. Hence why you see functions described as fun/2 not just fun. Because fun/2 and fun/3 are different function signatures.

2 Likes

Thanks.

There are other languages like C and C++, function signature is also combination of the name and the arity,
the signature not just name, but also arity. name != signature, I know this.

In my mind, paramter is about data, so I name parameters with nouns,
for me, in this case, fun_head or signature are all nice name,
but the call is a verb, this is a special choose.
Is there some deep reason? This is what I mean.

Yes. The first argument to these macros is indeed “function call”, not some “special syntax” for function signature. You call non-existing function and def* macros will then destructure it into name and parameters list.

2 Likes

Thank you very much. @hauleth

I guess, when write def* fun_name(a,b,c), we are call the non-eixisting function function_name with arguments
a,b,c at the compilte time.
def* destructure the call to function name and paramenters list, then togather with the function body
to create the function.

Any way this is meaningfull to me, an aha moment.