Use this tag for questions specifically about the rules, syntax, or behavior of function definitions but not for questions that happen to have code with function definitions in them but are not about function definitions.
Only use this tag if the issue at hand is about or related to the function definition.
A function definition is the definition of a user defined function along with the code the function contains. This is distinct from function-declaration which only defines the name and arguments of a function in certain programming languages. Example in C:
void SayHello(void); // Function declaration
void SayHello(void) { // Function definition
puts("Hello world!");
}
Some languages do not have function declarations and only have function definitions. Example in JavaScript:
function SayHello() { // Function definition; no forward declaration is required in JavaScript
console.log("Hello world!")
}
Function definitions are very common in programming. Many questions will contain them, but only use this tag if they are part of the question, and not just part of code being used to demonstrate an unrelated problem. Consider using other tags in these cases:
- Use function if the question is about functions in general.
- Use function-declaration if the question is about forward declarations of functions and not about defining the code of the function.