[IronPython] Writing new modules
Keith J. Farmer
kfarmer at thuban.org
Tue Aug 17 11:28:06 CEST 2004
Has anyone else played with J# at all?
The approach taken there is to define the Java versions of types,
separate from the CLR versions. That gives J# access both to the CLR
string and the Java string, as well as the numeric types of each, etc.
One downside to the current implementation is that there weren't (to my
knowledge) any implicit cast operators defined.
This commits the sin (IMHO) of exposing the source language to the
consumer. I think that sort of thing should be avoided. One way would
be to create a thin marshalling layer that allows the IL/bytecode to
internally use whatever, if necessary (a smart compiler could detect if
the type could be replaced outright), while exposing only the CLR or
Python type expected by the target environment.
There would be some overhead, but I don't think it'd be terribly bad.
After all, equivalent operations exist, more or less, in each
environment. It's the value that's of interest in the end.
This would allow export to the CPython world as a compiled module,
though the source could still be tainted with CLR-isms. A
transformation tool, however, could export CPython source that included
the marshalling layer explicitly, perhaps referencing a (future)
standard Python module.
More information about the Ironpython-users