There are no methods in Elixir - just functions!

Frankly, when and if you have a chance - correct them. Postel’s law is great in software but when it comes to human communication sloppiness resulting from “you know what I mean” tolerance seems to be cumulative over time ultimately resulting in statements that completely obfuscate the intended meaning.

That being said it needs the be recognized that “method” really refers to a function playing a particular role. Many moons ago I wasn’t allowed to use C++ on a particular project - so I resorted to C Interfaces and Implementations (1996) tactics which allowed me to be quasi-OO with just functions and structs. This is exactly the trap that Dave Thomas warns about in Programming Elixir 1.3 p.91:

Structs in particular might lead you into the darkness because you can associate functions with them in their module definitions. At some point, the old object-orientation neurons still active in the nether regions of your brain might burst into life and you might think, “Hey, this is a bit like a class definition.” And you’d be right. You can write something akin to object-oriented code using structs (or maps) and modules.

This is a bad idea. Not because objects are intrinsically bad, but because you’ll be mixing paradigms and diluting the benefits a functional approach gives you
.
Stay pure, young coder. Stay pure.

So even in the absence of methods inside the language, functions can still be used in method-like manner (topic of this recent discussion) which can be an even more insidious problem.

3 Likes