Any chance of "multiple inheritance" for DSLs?

MPS sounds like something I've been wanting for several years.  I'm very excited to see something real occurring in this field (although I am not a huge Java fan, which makes the "IntelliJ plugin" approach less than perfect for me, but I realize I'm in the minority there ;-)

As I've been thinking about the MPS project maintenance side of things, I came up with this question (and my apologies if it's already been asked, but a search didn't turn anything up)

Can a new language extend more than one language?

Here's why I ask (and this isn't the best possible example, but it was the first that leapt to mind):  If Person A extends C++ into C+WithDelegates and Person B extends C+ into C+WithAspects, and I'd like to have CWithDelegatesAndAspects, am I going to have to manually re-implement one of them as an extension of the other, or will I be able to "extend" the two into my new language?  I realize that in the general case there will be conflicts, but those conflicts can be resolved in the new language.  The conflict resolution should still be less work than re-implementing one or the other languageeditor+transformation.

Basically, if languages take the place of libraries, what is the process for working with, say 5-10 different "library languages"?  Libraries can coexist, because each library has to play nice and follow the rules of the common language.  At worst, you've got name collisions, which can be resolved by namespaces in any modern language.  But if the "library" is an extension to a language, directly modifying the structural, syntactic, and semantic graphs of the host language, then merging multiple "libraries" together is more involved.  This isn't just a namespace issue.  When two languages both extend the concept of "expression", which seems like it would be a reasonably common situation, some form of merging resolution will be needed.

I feel I should point out that I prefer C++ and Eiffel (with multiple inheritance) over Java and Smalltalk (single inheritance), so I tend to wonder about these things.  But when the multiple inheritance involves languages, I don't think it will be possible to workaround the problem the same way you can work around it when using class libraries.  Even if it can be worked around, I find the workarounds to be inelegant wastes of time -- delegation, for instance, requires duplicating the entire public interface as a set of callthrough functions.  Certainly, an IDE could provide that as a form of refactoring, but it still seems wasteful.  I think it will need to be addressed directly.

I also feel I should mention, hopefully without starting a flame war, that I prefer Eiffel's devoted effort to truly understand the nature of the problems with multiple inheritance, rather than C+'s "let's keep hacking on keywords until people shut up about it" approach.  Unfortunately, in my real work, I need C+'s speed more than I need Eiffel's conceptual cleanliness.  My point is that while multiple inheritance is a hard problem, it is not an unsolvable one, and I think that someone capable of successfully creating MPS is likewise capable of creating an elegant solution to the multiple inheritance issue as well.  And no, that isn't "sucking up".  As I say, I've wanted MPS for a long time, but figured it was just a pipedream.  I didn't think it could actually be made.  So seeing it exist, even in an EAP form, means the author is pretty impressive at making very abstract and complex systems run in the real world.

4 comments
Comment actions Permalink

Can a new language extend more than one language?

Yes, this should be possible.

At this time we don't support language inheritance directly. I mean that you can't declare relationships between languages.

Instead, the language extension is done with four major steps:

1. extend concepts in base language.

2. extend base actions (basically-autocompletion) to allow insertion (and other manipulation) of your concepts into model written in base language.

3. extend base typesystem. This way new concepts can be adapted to types known in base language.

4. define generator that secures transformation of new concepts into base concepts.

Nothing in this scheme prevents you from extending multiple languages.

Here's why I ask (and this isn't the best possible

example, but it was the first that leapt to mind):

If Person A extends C++ into C++WithDelegates and

Person B extends C++ into C++WithAspects, and I'd

like to have C++WithDelegatesAndAspects, am I going

to have to manually re-implement one of them as an

extension of the other, or will I be able to

"extend" the two into my new language?

I don't thing you really need 4th language here. What you need is to write you program in c++ with 2 extensions. In good language workbench you should be able to simply state your intention like: main_language="c++", extensions=(delegates, aspects)

You are right, it is pretty much like libraries in ide settings or compiler options.

Igor.

0
Comment actions Permalink

But when the multiple

inheritance involves languages, I don't think it will

be possible to workaround the problem the same way

you can work around it when using class libraries.

Even if it can be worked around, I find the

workarounds to be inelegant wastes of time --

delegation, for instance, requires duplicating the

entire public interface as a set of callthrough

functions.  

The composition would be acceptable replacement for multiple inheritance.

For instance, can be declared as composition of 2 features like:  collection {sorted = {..comparator..}, indexed }.

It is less generic then multiple inheritance because set of "features" is fixed in language. But is it possible at all to have class inherited simultaneously from List and SortedSet?

Igor.

0
Comment actions Permalink

Ahhhh...

This is what comes from letting myself go too far down a mental path without checking that I was on the right path in the first place...

For some reason, I got it in my head that you had to make up a "new language" to work with it, and that something similar to inheritance was the mechanism behind it.

BUT, if the actual approach involves "main_language" and "extensions", then the whole thing is a non-issue.  Very cool.  Sorry for using so much bandwidth due to my own confusion.

0
Comment actions Permalink

Don't worry about bandwidth :-) issue that you broached is very important. The idea of having mainlanguage+extensions is not current approach yet. You wont find it in the eap build. But we are going in this direction.

0

Please sign in to leave a comment.