[pypy-dev] adding support for Generic classes in the "/module/clr"

amit regmi.amit at gmail.com
Wed Dec 12 02:11:52 CET 2007

Support for generic classes

---IronPythonic way---------
from System.Collections.Generic import *
l = List[str]()
l.Add(3)        # fails with ValueError:  

d = Dictionary[str, int]()
d.Add('abc', 1)
d.Add('def', 2)
for i in d.Keys:
    print d[i]

So here in pypy-clr what we'd like to do is

    import System.Collections.Generic.LinkedList<str>
    l= System.Collections.Generic.LinkedList<str>()
    l.Add(3)        # throw ValueError exception

the import is to be analysed if its an import for a Generic Class and 
loaded as


The implementation of load_cli_generic_class is a BlackBox to me as of now.

 From the import line we can check if the class is a "generic" and then 
reflection can be used to determine:
a) Generic type
b) type arguments
c) Parameter attributes
.... and more

I hope somehow the existing build_wrapper could be used after putting 
some checks but I am not sure how.


More information about the Pypy-dev mailing list