an oop question

Chris Angelico rosuav at gmail.com
Fri Nov 4 11:25:00 EDT 2022


On Sat, 5 Nov 2022 at 02:18, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>
> On 4/11/22 12:50 am, Chris Angelico wrote:
> > In Python, everything is an object. Doesn't that equally mean that
> > Python is purely OOP?
>
> Depends on what you mean by "purely oop". To me it suggests a
> language in which dynamically-dispatched methods are the only
> form of code. Python is not one of those, because it has
> stand-alone functions.
>

Define "stand-alone". In Java, all code has to be associated with a
class file, but they can be static methods. A Java-like language in
which classes are themselves first-class objects (and thus static
methods are instance methods on the class) would, in a sense, have
nothing but dynamically-dispatched methods as the only form of code.
It wouldn't be materially different from regular Java though (at
least, not for the sake of this purity; having first-class classes
would probably have other benefits).

Pike code, like Java code, is always associated with an object or a
program (Pike's name for a class). However, built-in functions
(implemented in C) can stand entirely alone. Would Pike become "purely
OOP" if all standalone builtins were deemed to be methods of some
global object? It wouldn't materially change anything.

Maybe it's one of those terms that is useless for actual coding
(because practicality beats purity), but good for discussions?

Good for arguments, at least.

ChrisA


More information about the Python-list mailing list