Bugzilla – Bug 6182
Partial methodmaps
Last modified: 2014-07-10 17:34:30 PDT
It would be a neat feature to be able to split methodmaps among different files within a plugin, ie: // a.inc partial methodmap Object { public void SomeFunc(); }; // b.inc partial methodmap Object { public void OtherFunc(); }; Similar to c#'s partial classes: http://msdn.microsoft.com/en-us/library/wa80x488.aspx
In principle, I like the idea, and members of the dev team mentioned it as a possibility as well. Methodmaps are closer to C# extension methods, except that we only allow one block of them. I can guarantee we'll see extension methods on classes someday. The reason I'd prefer not to do it now is that methodmaps are intended to serve a very limited purpose in transitioning to an object-oriented API. If they deviate too far from classes, then we have to guarantee those features for classes, and I don't want to lock the type system into something we may not want to implement in a new compiler. I don't want to make the mistake of going too far in a hacky system and then having to preserve behavior we didn't fully specify or develop. I'm hugely in favor of extension methods - not sure about the utility of partial class. I'm interested in structural subtyping too which is related. They all require more careful type systems and for now I'm going to wait on a new compiler.