@@ 4,6 4,7 @@ def proximity(klass, mro):
return mro.index(klass)
def check_ambiguity(candidates, mros):
+ """ GvR's ambiguity checking """
def dominates(dom, sub,
orders=tuple(dict((t, i) for i, t in enumerate(mro))
for mro in mros)):
@@ 16,6 17,7 @@ def check_ambiguity(candidates, mros):
for dom, _func in candidates)]
def clos_mro(types_func_map, callsig):
+ """ David Mertz's clos mro """
siglen = len(callsig)
table = [(sig, func) for sig, func in types_func_map.iteritems()
if len(sig) == siglen
@@ 31,6 33,13 @@ def clos_mro(types_func_map, callsig):
class NoNextMethod(Exception): pass
class GF(object):
+ """ primary methods
+ TODO:
+ before/after/around
+ all before get executed first, bottom to top
+ all after get executed last, top to bottom
+ """
+
def __init__(self, mro=clos_mro):
self.mro = mro
self._reg = {}
@@ 0,0 1,41 @@
+
+Python 3000 - Adaptation or Generic Functions?
+by Guido van van Rossum
+April 5, 2006
+http://www.artima.com/weblogs/viewpost.jsp?thread=155123
+
+PEP: 3124
+Title: Overloading, Generic Functions, Interfaces, and Adaptation
+http://www.python.org/dev/peps/pep-3124/
+
+CLOS
+http://en.wikipedia.org/wiki/CLOS
+
+Generic Function
+http://en.wikipedia.org/wiki/Generic_function
+
+The Common Lisp Object System: An Overview by Richard P. Gabriel and Linda DeMichiel
+http://www.dreamsongs.com/NewFiles/ECOOP.pdf
+
+Generic functions vs mixins: a case study
+by Michele Simionato
+September 3, 2008
+http://www.artima.com/weblogs/viewpost.jsp?thread=237764
+
+Mixins considered harmful/1
+by Michele Simionato
+January 1, 2009
+http://www.artima.com/weblogs/viewpost.jsp?thread=246341
+
+Mixins considered harmful/2
+by Michele Simionato
+January 5, 2009
+In this post I clarify my position with respect to mixins, I show a few common design mistakes and I suggest some alternative solution.
+http://www.artima.com/weblogs/viewpost.jsp?thread=246483
+
+Mixins considered harmful/3
+by Michele Simionato
+April 3, 2009
+My series against mixins continues. This time I consider using proxies instead of mixins, and I pose a design problem which will be solved in the last issue.
+http://www.artima.com/weblogs/viewpost.jsp?thread=254367
+