Monday, March 3, 2014

Restricted Interfaces, Please

In Abiathar's extension API, there are two or three interfaces that would mess everything up if implemented by something other than Abiathar Core. They need to be interfaces because I don't want the extensions to need a reference to Abiathar's internal details, which may change drastically. It wouldn't really be a problem unless objects of the interface types didn't have to be passed back through the API, which they do. (Level wrappers.)

Also, in F#, Clojure, and (maybe) Haskell, there is an Option type that may or may not be an instance of Some, which contains a real value. Option is also subclassed by None, which is kind of the entire point of being an option type. Now, it's possible to inherit Option with some other class that breaks all the logic. This can't be stopped because Option has to be inheritable by Some and None to have an option.

What I really want is some way to restrict which assemblies can implement an interface or inherit a type. I at first thought adding a line like "InheritableBy etc" to the definition would work to allow only those types to inherit it, but this significantly increases compiler/parser complexity. Also, it would be difficult to make it not break when used in different assemblies (would a reference to the original be needed? that would defeat the purpose).

No comments:

Post a Comment