[Ironpython-users] Passing an IronPython function to C#

Dino Viehland dinov at microsoft.com
Sat Mar 17 23:51:58 CET 2012

Jeff wrote:
> IronPython's conversion code is, um, interesting -- Dino might understand it all,
> but I don't know if anyone else does -- so it's possible two different sets of
> conversions are being chosen. Now, this
> *shouldn't* be the case, but it's my hypothesis.

Ha!  Overload resolution is like Conway's game of life, you can know the rules,
but knowing the behavior is another time entirely...  Luckily this doesn't so much deal with
that rather than how our IList<T> wrapper is implemented in ConversionWrappers.cs.
The indexer is just doing a C# cast from the value to the T type.  That could easily
be changed to do a full Python conversion.

I think doing an is check first and only doing the conversion if it's not already the proper
type would be an alright change.  But it could be a little surprising in that sometimes you 
could get a new instance each time you access an element (e.g. a new delegate could be 
created each time).

More information about the Ironpython-users mailing list