From Edward Welbourne Thu Apr 8 14:22:57 1999 From: Edward Welbourne (Edward Welbourne) Date: Thu, 8 Apr 1999 14:22:57 +0100 Subject: [Types-sig] suggestion: replace class with a generic generator statement Message-ID: See http://www.chaos.org.uk/~eddy/dev/toy/python.html for links to details. These essays are nearing finality - feedback would help me clarify my ideas. For that matter, this list has gone deathly quiet ... hello, is there anyone there ? Synopsis: How to re-implement classes and instances (with comments on extending this to modules and packages). First mess with getattr (lookup.html). Then (object.html) replace the class statement with generator [where `.' ] name [tuple] `:' suite wherein the name is an identifier, the generator needs to evaluate to a function, the tuple must evaluate to a tuple (the bases, default value is ()) and the where (if given) must evaluate to a namespace (default is locals). Execution of a generator-statement proceeds as: bok = { '__name__': where.__name__ + '.' + name, '__file__': __file__ } obj, NS = apply(generator, tuple, bok) # generator must return a 2-ple. bind obj to the given name in where's namespace or locals execute suite in the namespace of the object NS where, typically, NS and obj will be very closely related objects ... Note that the bok part is one I've just invented; feel free to ignore it. It then suffices to define a few sensible generators (python.py). Unreserve the word class and add a suitable generator to builtins. Some thoughts on import are in there too (import.html). Note that NS.__setattr__ needs to be callable with args (key, value) if the suite attempts to set any names in its local namespace. If the suite wants to define a __setattr__ for inheritance by obj's instances (say), so with args (self, key, value), it has a potential problem with subsequent code in the suite trying to use this as the __setattr__ (it has the wrong signature). This can be bypassed by giving NS a __setattr__ which modifies some other object (e.g. obj or one of its attributes), while borrowing (as from a base) from that object so as to be able to see the changes it makes - but still hide a new __setattr__ behind the one it's using. Once the suite has terminated, NS gets thrown away (if not remembered in obj's namespace) and the object it modified has the inheritable __setattr__ we wanted for it. A major change all this wants is to the aquisition of global namespaces by subordinates: at present, a class statement executed inside a function body can't see the function's local namespaces, which is a severe (but not fatal) pain in the neck. One function, inner, within another, outer, naturally, has to have outer's globals as its globals - it can't access outer's locals because these may have ended their lifetime before inner gets called. Likewise, a method defined in a class defined within a function would have to have the function's globals as its globals. However, a class statement defined within a function is executed during the lifetime of the function's locals. I contend that the class statement should use, as its globals, the locals of the most-closely-enclosing function (or of the module if none, of course). Note that the function can see the file globals and provide access to them by transcribing them into its local namespace, so this hasn't altogether blocked the class from seeing the file globals. Eddy. From tim_one@email.msn.com Sun Apr 18 21:55:42 1999 From: tim_one@email.msn.com (Tim Peters) Date: Sun, 18 Apr 1999 16:55:42 -0400 Subject: [Types-sig] suggestion: replace class with a generic generator statement In-Reply-To: Message-ID: <000701be89dd$d2fb12c0$ed9e2299@tim> [Edward Welbourne] > See http://www.chaos.org.uk/~eddy/dev/toy/python.html for links > to details. > These essays are nearing finality - feedback would help me clarify my > ideas. For that matter, this list has gone deathly quiet ... hello, is > there anyone there ? Apparently not: it's been more than a week since you asked, and this appears to be the first reply! Don't know about anyone else, but I'm deathly overloaded with other stuff already, and am really writing this just to test the mail link . a-generator-stmt-may-or-may-not-be-a-great-idea-but-if-you-don't-spell- at-least-one-form-of-it-"class"-it's-dead-on-arrival-ly y'rs - tim From M.Faassen@vet.uu.nl Mon Apr 19 09:36:51 1999 From: M.Faassen@vet.uu.nl (Martijn Faassen) Date: Mon, 19 Apr 1999 10:36:51 +0200 Subject: [Types-sig] suggestion: replace class with a generic generator statement References: <000701be89dd$d2fb12c0$ed9e2299@tim> Message-ID: <371AEB22.96A88B9F@pop.vet.uu.nl> Tim Peters wrote: > > [Edward Welbourne] > > See http://www.chaos.org.uk/~eddy/dev/toy/python.html for links > > to details. > > These essays are nearing finality - feedback would help me clarify my > > ideas. For that matter, this list has gone deathly quiet ... hello, is > > there anyone there ? > > Apparently not: it's been more than a week since you asked, and this > appears to be the first reply! Don't know about anyone else, but I'm > deathly overloaded with other stuff already, and am really writing this just > to test the mail link . Hey, I was there; I just didn't have a reply. I browsed through the pages but I'm afraid it went over my head. I'll try again later and try to offer some comments on what I didn't understand. (bug me if you don't hear anything! :) Regards, Martijn From Vladimir.Marangozov@inrialpes.fr Mon Apr 19 13:03:04 1999 From: Vladimir.Marangozov@inrialpes.fr (Vladimir Marangozov) Date: Mon, 19 Apr 1999 14:03:04 +0200 (DFT) Subject: [Types-sig] suggestion: replace class with a generic generator statement In-Reply-To: from "Edward Welbourne" at "Apr 8, 99 02:22:57 pm" Message-ID: <199904191203.OAA04106@pukapuka.inrialpes.fr> Edward Welbourne wrote: > > See http://www.chaos.org.uk/~eddy/dev/toy/python.html for links to details. > These essays are nearing finality - feedback would help me clarify my > ideas. For that matter, this list has gone deathly quiet ... hello, is > there anyone there ? > Hi, After reading the essays, I have an intuition about the overall idea, but I'm unclear on what the class/object model looks like. Edward, could you elaborate on your vision about the relationships between objects/classes/metaclass(es)/types and which of these entities exist according to you? I understand that the generator (function) concentrates on packaging but this is what the class statement does for objects (although not so dynamically as you seem to suggest), and this is what metaclasses are supposed to do for classes if they see the light, etc. This is what meta^N-objects are supposed to do for meta^(N-1)-objects if you wish ;-) Creating, registering and discovering object types on the fly is okay, (if I understand correctly your writing) but I lack a global vision on your object model... After all, it could be that I'm completely missing the point, so I'd better ask for a clarification right now, from an end-user point of view, before proceeding with comments on your ideas. Thanks. PS: I've been reading lately a recent book by Ira Forman, Scott Danforth titled "Putting metaclasses to work" (Addison-Wesley 1999) (http://cseng.aw.com/bookdetail.qry?ISBN=0-201-43305-2&ptype=0) which, besides their object model & MOP, reveals another point of view on how property packaging can be done (not necessarily very different from what you're proposing, but I'm not sure...) -- Vladimir MARANGOZOV | Vladimir.Marangozov@inrialpes.fr http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252 From paul@prescod.net Mon Apr 19 20:39:14 1999 From: paul@prescod.net (Paul Prescod) Date: Mon, 19 Apr 1999 14:39:14 -0500 Subject: [Types-sig] suggestion: replace class with a generic generator statement References: Message-ID: <371B8662.4D943FD@prescod.net> Edward Welbourne wrote: I'm another person that didn't really understand the proposal. I think that you are introducing so much new stuff at once that it is very difficult for a reader to figure out when they got lost. -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "The Excursion [Sport Utility Vehicle] is so large that it will come equipped with adjustable pedals to fit smaller drivers and sensor devices that warn the driver when he or she is about to back into a Toyota or some other object." -- Dallas Morning News From tismer@appliedbiometrics.com Mon Apr 19 21:18:22 1999 From: tismer@appliedbiometrics.com (Christian Tismer) Date: Mon, 19 Apr 1999 22:18:22 +0200 Subject: [Types-sig] suggestion: replace class with a generic generator statement References: <371B8662.4D943FD@prescod.net> Message-ID: <371B8F8E.4AE6CA1B@appliedbiometrics.com> Paul Prescod wrote: > > Edward Welbourne wrote: > > I'm another person that didn't really understand the proposal. I think > that you are introducing so much new stuff at once that it is very > difficult for a reader to figure out when they got lost. I also understood hardly a word. So I was waiting for someone else to speak up :-) Anyway, I understood and like the idea to build something spartanic with the minimum C and try to build the "rest" with Python. After reading the proposal, I think I got it for some minutes, but then -pop- after 5 minutes I'm as dumb as before. Maybe a very, very short summary which fits on a page would do. If it doesn't fit on a page, I won't fit my brains. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home