diff --git a/Demo/metaclasses/index.html b/Demo/metaclasses/index.html
index 269dc6938a5..ee91f8f1a22 100644
--- a/Demo/metaclasses/index.html
+++ b/Demo/metaclasses/index.html
@@ -23,7 +23,7 @@
XXX This is very much a work in progress.
Fulton has used it in his Extension
Classes package. (It has also been referred to as the ``Don
-Beaudry hack, but that's a misnomer. There's nothing hackish
+Beaudry hack,'' but that's a misnomer. There's nothing hackish
about it -- in fact, it is rather elegant and deep, even though
there's something dark to it.)
@@ -182,6 +182,11 @@ Writing Metaclasses in Python
in the future they will really be the same thing (at which point you
would be able to derive subclasses from built-in types).
+At this point it may be worth mentioning that C.__class__ is the
+same object as B.__class__, i.e., C's metaclass is the same as B's
+metaclass. In other words, subclassing an existing class creates a
+new (meta)inststance of the base class's metaclass.
+
Going back to the example, the class B.__class__ is instantiated,
passing its constructor the same three arguments that are passed to
the default class constructor or to an extension's metaprogramming
@@ -229,7 +234,7 @@
Writing Metaclasses in Python
x = MySpecialClass()
-y = Myspecialclass()
+y = MySpecialClass()
print x.__class__, y.__class__
@@ -468,7 +473,7 @@ Real-life Examples
Eiffel.py
-ppp
+
Uses the above generic metaclass to implement Eiffel style
pre-conditions and post-conditions.
@@ -481,6 +486,12 @@ Real-life Examples
+
Simple.py
+
+The example module used above.
+
+
+
A pattern seems to be emerging: almost all these uses of
@@ -493,6 +504,82 @@
Real-life Examples
as well. This needs more research. Perhaps a metaclass could be
provided that allows stackable wrappers...
+
+
+Things You Could Do With Metaclasses
+
+There are lots of things you could do with metaclasses. Most of
+these can also be done with creative use of __getattr__, but
+metaclasses make it easier to modify the attribute lookup behavior of
+classes. Here's a partial list.
+
+
+
+
+
+- Enforce different inheritance semantics, e.g. automatically call
+base class methods when a derived class overrides
+
+
- Implement class methods (e.g. if the first argument is not named
+'self')
+
+
- Implement that each instance is initialized with copies of
+all class variables
+
+
- Implement a different way to store instance variables (e.g. in a
+list kept outside the the instance but indexed by the instance's id())
+
+
- Automatically wrap or trap all or certain methods
+
+
+
+- for tracing
+
+
- for precondition and postcondition checking
+
+
- for synchronized methods
+
+
- for automatic value caching
+
+
+
+
+
- When an attribute is a parameterless function, call it on
+reference (to mimic it being an instance variable); same on assignment
+
+
- Instrumentation: see how many times various attributes are used
+
+
- Different semantics for __setattr__ and __getattr__ (e.g. disable
+them when they are being used recursively)
+
+
- Abuse class syntax for other things
+
+
- Experiment with automatic type checking
+
+
- Delegation (or acquisition)
+
+
- Dynamic inheritance patterns
+
+
- Automatic caching of methods
+
+
+
+
+
+
+
+Credits
+
+Many thanks to David Ascher and Donald Beaudry for their comments
+on earlier draft of this paper. Also thanks to Matt Conway and Tommy
+Burnette for putting a seed for the idea of metaclasses in my
+mind, nearly three years ago, even though at the time my response was
+``you can do that with __getattr__ hooks...'' :-)
+
+
+
+
+