
Philippe Mori wrote:
Well for exercice 2-1, I think I have a solution that is a little better because it detect when C and X are of the same type and this lead to a reduction of specilizations that are required for replacement of complex expressions.
The extra boolean parameter automatically detect when a replacment is possible for arbitrary complex X that match C.
This could probably be 'improved' so you don't need the boolean in each specialization. Hint: The Fundamenetal Theorem of Software Engineering.
*** I'm not sure how to add this solution to the Wiki page without making a long answer that have both answer. For me, it seems that each post should be independant (as in a news group).
[code snipped] I suppose you could just append a ---- and your answer. Then Wiki would output a pretty visible separator. If you don't like that idea, you could factor the answers into several pages. When adding code to Wiki, an advice: Before the code snippet, add a space and <nowiki>. After the code snippet, add a </nowiki>. Unfortunately I didn't know this when I began adding answers.