Re: Joy of this, Joy of that

Liste des GroupesRevenir à s math 
Sujet : Re: Joy of this, Joy of that
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.os.linux.misc
Date : 23. Nov 2024, 22:36:38
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vhtht6$1s5d5$5@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
User-Agent : Pan/0.161 (Chasiv Yar; )
On Sat, 23 Nov 2024 08:26:26 +0000, Pancho wrote:

On 11/23/24 01:41, Lawrence D'Oliveiro wrote:
>
“Metaclasses” were just a bit of a hack to implement what Python would
call “classmethods”.
 
I think the Smalltalk idea of treating classes as objects, is the
opposite of a hack.

That is an elegant idea, but I don’t think it’s what Smalltalk did -- not
with metaclasses, anyway. If you look at the draft (abandoned) ANSI
Smalltalk spec <https://github.com/johnwcowan/smalltalk-standard>, it says
“because classes are not specified as the implementers of behavior,
metaclasses are not needed to provide the behavior of class objects”.

This is in contrast to Python, where metaclasses are very much an integral
part of the behaviour of classes.

I would say C++ static methods and static variables are a hack.

They are there to provide access to the innards of a private/protected
class, without having to go through instances of that class. In a language
like Python, which doesn’t bother constraining visibility to the innards
of a class, they are just a convenience for grouping purposes, nothing
more.

Much more useful are classmethods, which get passed the class object
itself as an argument. But that’s only possible in a dynamic language, not
like C++, or even Java or C♯.

C# type reflection is a hack.

Is that like the convoluted “reflection” API in Java? (Mind you, most APIs
in Java seem to be convoluted ...)

Just as value types are a hack in C#. Things that
are sensible for performance reasons, but that add complexity.

Presumably, like Java, these mechanisms are there to avoid the need for
the services of the full language compiler at runtime.

It was easy to see where Python metaclasses came from.

Not really. Which language used metaclasses to instantiate classes before
Python?

Python also does multiple inheritance. And it does it quite nicely,
benefiting from lessons learned in earlier attempts at “linearization”
(coming up with a consistent and minimally-surprising method resolution
order across all the base classes).

Date Sujet#  Auteur
22 Dec 24 o 

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal