From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,c52c30d32b866eae X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,2ea02452876a15e1 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,c52c30d32b866eae X-Google-Attributes: gid1108a1,public From: amitp@Xenon.Stanford.EDU (Amit Patel) Subject: Re: Real OO Date: 1996/05/07 Message-ID: <4moeuf$h9n@nntp.Stanford.EDU>#1/1 X-Deja-AN: 153568309 references: <4m5ugh$ben@nntp.Stanford.EDU> organization: Computer Science Department, Stanford University. newsgroups: comp.lang.eiffel,comp.lang.ada,comp.object Date: 1996-05-07T00:00:00+00:00 List-Id: Robert A Duff wrote: >In article <4m5ugh$ben@nntp.Stanford.EDU>, >Amit Patel wrote: >>Another example is a compiler, which has a fixed set of intermediate >>representation data variants (add, mul, mov, etc.) and a varying >>number of operations (code optimization passes). Each optimization >>pass can be put into a separate module, and new optimization passes >>can be added without modifying the intermediate code definition. > >What if the "representation data variants" are *not* fixed. How do you >design things so that it's easy to add a new one of those, and *also* >easy to add a new optimization pass? "Design Patterns" by Gamma et al >seems to force you to decide which of those two dimensions you might >want to modify in the future, and design accordingly. But what if >*both* are likely to need modification? If both really need to be modified, there's a problem! How are old optimization passes supposed to work with new data, and how to do new optimization passes work with old data? If you're extending in two dimensions, it's very hard to take two extensions and combine them. For example, the original compiler has two data variants: A and B. There are two optimization passes, 1 and 2. Bob extends the system to have a new data variant, C. He may have to modify 1 and 2 to work with C, if union types are used. Therefore, Bob thinks it's better to use objects. Amit extends the system to have a new optimization pass, 3. He may have to modify A and B to work with 3, if object types are used. Therefore, Amit thinks it's better to use union types. Multimethods provide a partial solution to the problem. You can add new data variants, AND define new operations on existing data variants. The problem, though, is combining Amit's work with Bob's work. Amit shouldn't be expected to make 3 work with C, because he didn't know about C. Bob shouldn't be expected to make C work with 3, because he didn't know about 3. The case still has to be defined, though. So if you choose single-dispatch objects, you can extend the system with new data variants. You can combine extensions from different places and have the system work. If you choose tagged unions, you can extend the system with new code. You can combine extensions from different places and have the system work. If you choose multimethods, you can extend the system with data variants. You can extend the system with new code. You can't expect extensions from different sources to work (in general). It seems like you get two out of three! - Amit