Deutsch English Français Italiano |
<vhtplb$1tioh$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Pancho <Pancho.Jones@proton.me> Newsgroups: comp.os.linux.misc Subject: Re: Joy of this, Joy of that Date: Sat, 23 Nov 2024 23:48:59 +0000 Organization: A noiseless patient Spider Lines: 96 Message-ID: <vhtplb$1tioh$1@dont-email.me> References: <vhigot$1uakf$1@dont-email.me> <6iKdnTQOKNh6AqD6nZ2dnZfqn_idnZ2d@earthlink.com> <20241120081039.00006d2a@gmail.com> <vhlium$93kn$1@dont-email.me> <vhmprp$iaf1$1@dont-email.me> <LASdnSkA69I3yKL6nZ2dnZfqnPWdnZ2d@earthlink.com> <vhoeap$r8gq$2@dont-email.me> <vhpmq3$14s79$2@dont-email.me> <vhq1f7$16bou$1@dont-email.me> <vhqm4g$1aarf$1@dont-email.me> <vhr2r7$1cdln$1@dont-email.me> <vhr8hh$1ddh7$2@dont-email.me> <vhr9u1$1dh3s$1@dont-email.me> <vhrbsr$1dqca$2@dont-email.me> <vhs3ji$1kb5c$1@dont-email.me> <vhtht6$1s5d5$5@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 24 Nov 2024 00:49:05 +0100 (CET) Injection-Info: dont-email.me; posting-host="8cce37f5dee4f992fb90ec878c5ed748"; logging-data="2018065"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/XnB07yHOIXd8nkMxjAjVGY8/CX0MnaR4=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:XtZgVYv+ofnzioluEcDwYcEW7ag= In-Reply-To: <vhtht6$1s5d5$5@dont-email.me> Content-Language: en-GB Bytes: 5218 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.