Hi,

The .NET translator ambles on and I can now translate a lot of stuff relating to the .NET object model. Recently I've been working on mapping .NET's static method overloading onto Parrot's MMD. With some evil tricks I got it to work - almost.

The real issue is that .NET knows what method will be called statically. It doesn't do the whole "find what to call at runtime" thing Parrot does, but of course if I want to interoperate with other languages (which is the whole point of my project) then I need to translate the code in such a way that it works using Parrot primitives. So using Parrot's MMD it is.

The problem I've hit is that dispatch is based on the runtime type of objects being passed. That's fine, until the object we're passing is null, then it's just a null PMC with no relation whatsoever to a particular ParrotClass, and so the dispatch fails. I don't see any way of "creating" a null of a particular type, but please do correct me if I'm missing something here.

This problem would go away if I had a way of doing a find_global or findmethod but also specifying the types that make up the signature. Kinda like those find ops but taking an extra PMC which would be a string array of type names. In fact, I think we're going to need this for Perl 6 anyway, since there you can use &sub_name<type1, type2> to get a reference to one of a number of multi-subs. This solves my problem because the "dispatch" then depends on the static types, and passing a null will be fine.

Anyway, if this sounds sane my plan is to implement ops as I described. I'll do them in my .NET dynops, but if it's agreed they're wanted in Parrot itself and are blessed with names, I'll happily move them into the core Parrot ops.

Comments most welcome,

Jonathan

Reply via email to