3 ms·
Yes. Although I disagree that what the GP rebuts what he was intended to rebut, I agree with his particular point, viz., hat the idea of OOP doesn't necessaril
by jfarmer 13y ago
Yes. Although I disagree that what the GP rebuts what he was intended to rebut, I agree with his particular point, viz., hat the idea of OOP doesn't necessarily entail the idea of classes, although most OOP languages implement many principles of OOP through the class/instance mechanism.
JavaScript, for example, is an OOP language without classes per se. Indeed, many JavaScript programmers avoid what little built-in class-like behavior JavaScript has and implement their own class definition/inheritance/instantiation mechanisms via things like Object.extend.
And although it's rare, one can define "singleton" methods directly on objects in Ruby, too:
animal = "Dog"
# This is now defined only on the animal object
# and no other String instance
def animal.bark!
"Woof woof!"
end
animal # => "Dog"
animal.class # => "String"
animal.bark! # => "Woof woof!"
So, JavaScript is an example of an OOP language without classes at all (or at least one where you often pretend they don't exist) and Ruby is an example of an OOP language which has classes but where function definitions are not constrained to classes.
This is the point I understood the GP to be making.