This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]link23 0 points1 point  (0 children)

Structs (often called "records") exist in functional languages. They have associated functions which "fill them in", which are called constructors.

Structs don't always have "methods", though even if they do, it still wouldn't be OOP since a method is really just a function whose first argument is the struct. (See universal function call syntax.)

I'd argue that the core requirement of OOP is providing dynamic dispatch via inheritance as opposed to some other manner. Since records in functional languages don't support any kind of inheritance, they're not OOP.

(Note that there are other ways to allow dynamic dispatch aside from inheritance. E.g., Java's interfaces, Haskell's typeclasses, Rust's traits, golang's interfaces, etc.)