Mondego/spacetime

Create @mutation

Closed this issue · 3 comments

After extensive discussion with @lordnahor, we agreed on why mutation needs to exist. Imagine the following scenario: Car is a base type, and two mutations are ElectricalCar and MechanicalCar. ElectricalCar contains all dimensions regarding the electrical components of a car. The MechanicalCar contains all dimensions for its mechanical parts. With that in mind:

a) Inheritance is a not a good fit. Car should not have any electrical or mechanical dimensions to it if we wish to maintain an aspect-oriented design.

b) Projection is not a good fit either. Projections are great for aspect-oriented design, but they have a fundamental premise: no new information is added. This means that if ElectricalCar was a projection of Car, dimensions can only be removed, not added. As soon as we need to do add a new dimension, the object needs to be independent so that this new information is not added. So if ElectricalCar adds a dimension like NominalVoltage, it needs to exist in PCC as a set type. If NominalVoltage was in Car, ElectricalCar could be just a projection of Car, created dynamically.

c) A projection of an inheritance works, but is clunky. We could have TempElectricalCar inherit from Car, and add the dimensions it needs, like NominalVoltage. Then ElectricalCar could be a projection of TempElectricalCar, removing all the unwanted fields, like the position of the Car. While this works, its not only ugly (we have to create a type that never gets used), it also not very efficient.

The solution is the creation of a new type, called @mutation. Mutation is, for all intents and purposes, a entirely new @pcc_set. The difference is that classes marked as mutations get added to the same list derived classes do. ElectricalCar would be a @mutation(Car). Thus, everytime get(Car) is called, a Car would be constructed with only the existing fields in ElectricalCar. If get(ElectricalCar) is called, only ElectricalCars are returned (as opposed to projection, where ALL cars would be returned).

We are also considering removing inheritance as a means to declare that two types share a relationship. Inheritance would be used only for its programming language intent, and the inheritance behavior would come from the declaration of mutation. This way it would also be possible to have inheritance without the respective pcc/spacetime behavior (problem with RouteRequest/Route in INF295). If inheritance behavior is desired, we can just use inheritance + mutation.

wait a minute.... this needs to be discussed. Basically any time you want to introduce a concept with a word that doesn't ring a bell, chances are the concept is wrong or the word is wrong. Let's not reinvent the wheel

Yes, we need to discuss it. I added it here so we wouldn't forget. We can talk next meeting (Monday?)

We decided to change the name to isa, following the same logic previously discussed. Committed in Mondego/pcc@449d770 , not yet tested.