Re: Joy of this, Joy of that

Liste des GroupesRevenir à s math 
Sujet : Re: Joy of this, Joy of that
De : Pancho.Jones (at) *nospam* proton.me (Pancho)
Groupes : comp.os.linux.misc
Date : 24. Nov 2024, 00:48:59
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vhtplb$1tioh$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
User-Agent : Mozilla Thunderbird
On 11/23/24 21:36, Lawrence D'Oliveiro wrote:
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”.
 
The full quote...
"Class objects have no special significance other than having names and having behaviors and state distinct from that of
their associated instance objects. Unlike classic Smalltalk definitions [Goldberg83], they are not defined as being the
containers or implementers of their instances' behavior. The techniques used to implement the behavior of objects is left to
the implementers. Finally, because classes are not specified as the implementers of behavior, metaclasses are not needed
to provide the behavior of class objects. "
I learnt Smalltalk nearly 40 years ago, needless to say I learnt from the Goldberg Smalltalk-80 bluebook, not the current spec.
To be honest, I don't have an idea what classes not being the implementers of instance behaviour means. Where is instance behaviour implemented?

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,
No, C++ static means class method or class variable.

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 ...)
 
Dunno, I very rarely used it. It was more for things like generic serialisation to JSON.

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.
 
No they are there for performance, because you don't want to have to do a malloc and instance initialisation for every number you use.

It was easy to see where Python metaclasses came from.
 Not really. Which language used metaclasses to instantiate classes before
Python?
 
erm!, erm! I know this one... Smalltalk. Smalltalk-80 if you want to be picky.

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).
Yeah, we discussed this in the past. I'm totally unconvinced of the desirability of complex multiple inheritance linearization.
I'm actually quite unconvinced by Python.

Date Sujet#  Auteur
22 Dec 24 o 

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal