-3

I understand the difference between methods and functions. I also understand all methods are functions but not all functions are methods. I always refer to methods as functions. It feels like a more natural term, probably because in PHP the word function is right next to the name of the method. However method seems to be a more precise word. I'm wondering if I'm misusing the term function and if it's a bad habit.

Is this use of the term function when referring to methods frowned upon or problematic?

Goose
  • 1,918

1 Answers1

-3

Homonyms usually become more dangerous to use the closer they are. No one is going to confuse your use of "table" (array of numbers) with a "table" (wooden furniture), but "function" (piece of code) vs. "function" (mapping from input to output) is often not disambiguated by context.

Therefore, the term "function" to mean "procedure" is problematic: it's close to the meaning of "function" in a closely related field (maths), but categorically different in an important respect (a mathematical function yields a value, while a "function" that is really only a method may not). This makes the term awkward and liable to cause serious misunderstanding.

Kilian Foth
  • 110,899