Is it possible an any way to change the class of an instance to its parent or sister?
It's quite a simple question in all its complexity but I will still give you context: The parent is 'Expression' with children 'Term', AdditiveExpression', 'ExponentialExpression', 'MultiplicitiveExpression', with 'AdditiveExpression' having a very similar child called 'ComplexTerm'. As you might have guessed, it is a mathematical mini-framework. The idea is that they all override the 'Expression' basic methods (or adhere to the 'Expression' protocol, I'm slightly undecided or which approah to take at this moment) so that I can ask for any expression like this:
So that I know I can tell anyExpression to multiply:anotherExpression. The actual overrides will be different in themselves but all take and return the 'Expression' type. The thing is I'd like to be able to modify expressions, that is if I had a 'Term' called 'a' and an 'AdditiveExpression' called 'b' and said
naturally a must result in an additive expression ie x(y+z)=xy+xz, so I would like to be able to modify the class of 'a' from 'Term' to 'AdditiveExpression', thus allowing me to treat these as mathematical objects that manage themselves rather that something I have to be able to predict.
Anyway, I probably made that question much more complex than the first line of this post.
Thanks in advance,
Richard
It's quite a simple question in all its complexity but I will still give you context: The parent is 'Expression' with children 'Term', AdditiveExpression', 'ExponentialExpression', 'MultiplicitiveExpression', with 'AdditiveExpression' having a very similar child called 'ComplexTerm'. As you might have guessed, it is a mathematical mini-framework. The idea is that they all override the 'Expression' basic methods (or adhere to the 'Expression' protocol, I'm slightly undecided or which approah to take at this moment) so that I can ask for any expression like this:
Code:
- (Expression *) doSomething:(Expression *)anyExpression
Code:
[a multiply:b];
Anyway, I probably made that question much more complex than the first line of this post.
Thanks in advance,
Richard