From: mailbox@dmitry-kazakov.de   
      
   On Mon, 05 Feb 2007 00:31:58 +0100, Seweryn Habdank-Wojewódzki wrote:   
      
   > Dmitry A. Kazakov wrote:   
   >   
   >>>> procedure Bar (X : Numeric'Class); -- Done   
   >>   
   >> But I didn't propose overloading. Bar as declared above has exactly one   
   >> body.   
   >   
   > Ok. Then show me an example of implementation. I suppose that inside this   
   > function you are doing something hard.   
      
   Why? The question we consider is when   
      
    Bar(X : Numeric)   
      
    is better than   
      
    Bar (X ; Numeric'Class);   
      
   Implementation is irrelevant and it will barely differ in both cases. A   
   sufficient difference is that the latter is a proper procedure and the   
   former is template to be instantiated for each member of Numeric'Class.   
      
   >>>>>>>>>> * : T x T -> T   
   >>>>>>>>>>   
   >>>>>>>>>> But what is needed is   
   >>>>>>>>>>   
   >>>>>>>>>> * : T1 x T1 -> T2   
   >>> [...]   
   >>>> Yes, this is how it works. Because type_C is replaced by a class of   
   >>>> types. So the signature of * is:   
   >>>>   
   >>>> * : T'Class x T'Class -> T'Class   
   >>>>   
   >>>> where T'Class = {T, T1, T2, T3, ...}   
   >>>>   
   >>>> This is a sufficiently more powerful type system than generics.   
   >>>   
   >>> Show me the implementation that T * T - > T and T1 * T1 -> T2   
   >>> but T2 * T2 -> T3, and T3 * T3 -> T3. Because just from this 2 line this   
   >>> is not clear that such a sequence works.   
   >>   
   >> This is quite straightforward. Ti is a member of class T.   
   >   
   > And the code? Ti is a member? We talked about types not fieds/members?   
      
   Member = element of the set. Ti is a member of {T, T1, T2, ...}   
      
   >> So any argument   
   >> of Ti is automatically converted to T'Class where the latter is expected.   
   >> Therefore * has only one body it is defined for the whole class T.   
   >   
   > And what if the * implementations independent. If the algorithm is   
   > completely different? Like * == multiplication of numbers and * as   
   > composition of functions, and * as convolution of some special functions?   
      
   Then it would not be a case for meta programming (either generic or   
   class-wide), because * could not be expressed in terms of operations of the   
   class = not a generic algorithm.   
      
   [ * can still be made virtual and have a compiler support for defining its   
   type-specific bodies. But that is a different story. ]   
      
   >> The   
   >> implementation of the body is similar to a generic body, it is defined in   
   >> the operations of the class. To have this * must be decomposable into   
   >> operations of T and T'Class. That is the basics of generic programming.   
   >   
   > "Generic" or just you are using inheritance?   
      
   Generic programming = meta programming > programming with generics.   
      
   >>> Yes. All. Again look what you can say when you want ask the class in   
   >>> compile time. Again Boost::trains. Again example of the is_special_kind   
   >>> template. so this is very easy to maintain big code.   
   >>   
   >> Well, if you honestly believe that templated code is maintainable then I   
   >> cannot imagine how we could come to an agreement.   
   >   
   > Tell me why not?   
   [...]   
      
   I am not aware of any scientific studies concerning this issue. So my   
   impressions are based solely on the code reviews I am making as a software   
   architect. I also remember a case when some software was completely   
   redesigned with the goal to remove STL. It was unmaintainable. But again it   
   is my personal opinion.   
      
   And it would be a shameless off-topic in comp.ai.fuzzy...   
      
   >> This is not what I want. The requirement is to compile:   
   >>   
   >> fuzzy_set_type A = ... // a singleton set;   
   >> fuzzy_set_type B = ~A;   
   >>   
   >> Observe difference.   
   >>   
   >> Lazy expressions might be OK, but it is a different representation of the   
   >> set. That was the whole point I was making.   
   >   
   > What you mean that this is different representation? You mean that set B is   
   > defined not directly, by points and their membership? This is not   
   > disavantage. This is a feature of the understanding of programming, that   
   > you do not need to explicitly construct set B, to calculate their   
   > membership.   
      
   I don't make a point of advantages, that's aside. My point is that you have   
   more than one representation of fuzzy sets. Period.   
      
   The consequence of this is that there exist good chances that the   
   representations will be unknown until run-time and required dynamic   
   switching. Therefore a decision to bind representation with a type rather   
   than a subtype is a design decision of potentially catastrophic effect.   
   Generics force you to take such decisions early, and run into troubles   
   later.   
      
   --   
   Regards,   
   Dmitry A. Kazakov   
   http://www.dmitry-kazakov.de   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|