digitalmars.D - Pyd: Using the new mixins
- Kirk McDonald (36/39) Feb 17 2007 Revision 100 of Pyd uses the new mixins to automatically generate "shim"...
- Walter Bright (2/4) Feb 17 2007 This is such great news. It shows we are going in the right direction.
- Kirk McDonald (8/12) Feb 17 2007 Note that this only means a reduction in the amount of code needed to
Revision 100 of Pyd uses the new mixins to automatically generate "shim"
classes, one of which must be made for every class which is exposed to
Python. (Revision 100 should be considered semi-broken, since I got all
the big stuff done, but a few details need to be gone over. Also, it
requires DMD 1.005, which GDC is not yet up to par with, so Linux
support is currently broken.)
There's little to show for this. The major effect of revision 100 is a
vast /reduction/ in code. Wrapping a class is now as simple as:
class Foo {
void bar() {
writefln("Foo.bar");
}
}
extern(C) void PydMain() {
module_init();
wrap_class!(
Foo,
Def!(Foo.bar)
);
}
This now properly handles all polymorphic behavior between D and Python:
// A D function
void polymorphic_call(Foo f) {
f.bar();
}
class PyFoo(Foo):
def bar(self):
print "PyFoo.bar"
p = PyFoo()
polymorphic_call(p)
PyFoo.bar
And /that/ is quite something.
--
Kirk McDonald
http://kirkmcdonald.blogspot.com
Pyd: Connecting D and Python
http://pyd.dsource.org
Feb 17 2007
Kirk McDonald wrote:The major effect of revision 100 is a vast /reduction/ in code.This is such great news. It shows we are going in the right direction.
Feb 17 2007
Walter Bright wrote:Kirk McDonald wrote:Note that this only means a reduction in the amount of code needed to /use/ Pyd. Pyd itself is slightly larger and more complicated. :-) -- Kirk McDonald http://kirkmcdonald.blogspot.com Pyd: Connecting D and Python http://pyd.dsource.orgThe major effect of revision 100 is a vast /reduction/ in code.This is such great news. It shows we are going in the right direction.
Feb 17 2007








Kirk McDonald <kirklin.mcdonald gmail.com>