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: 103376,2ea02452876a15e1 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,c52c30d32b866eae X-Google-Attributes: gid1108a1,public From: "Colin James III (The Rt Rev'd)" Subject: Re: Real OO Date: 1996/05/01 Message-ID: <4m82jl$8j1@mtinsc01-mgt.ops.worldnet.att.net>#1/1 X-Deja-AN: 152432029 references: <4m5ugh$ben@nntp.Stanford.EDU> <4m80qu$jn3@watnews1.watson.ibm.com> content-type: text/plain; charset=us-ascii organization: CEC Services, LLC mime-version: 1.0 newsgroups: comp.lang.ada,comp.object x-mailer: Mozilla 1.22ATT (Windows; U; 16bit) Date: 1996-05-01T00:00:00+00:00 List-Id: Norman Cohen at Watson Research Center of IBM is slipping again, perhaps becoming infirm. This again has nothing whatsoever to do with Eiffel, but lots to do with dead Ada. ------------------------------------------------- ncohen@watson.ibm.com (Norman H. Cohen) wrote: >In article <4m5ugh$ben@nntp.Stanford.EDU>, amitp@Xenon.Stanford.EDU >(Amit Patel) writes: > >|> 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. >|> >|> If one tried to implement this with objects, then each optimization >|> pass would be a method on the object. To add a new optimization, you >|> have to modify *every* data variant. > >An optmization is an operation on a sequence of instructions, not on an >instruction. It makes no sense to apply an Optimize operation to an ADD >instruction. > >Rather, if there were an abstract type for instructions, with >subclasses for various categories of instructions, there would >be a set of operations defined for all kinds of instructions, such as: > > function Operand_Count (Instruction: Instruction_Type) return Natural; > function Operand > (Instruction: Instruction_Type; Position: Positive) > return Operand_Type; > function New_Instruction > (Opcode: Opcode_Type; Operands: Operand_List_Type) > return Instruction_Type'Class; > function Is_Associative (Instruction: Instruction_Type) return Boolean; > ... > >Operand_Type would also be a class, with subclasses for general >registers, floating-point registers, real immediate values, integer >immediate values, and so forth. (There would be a dispatching Image >function defined for Operand_Type, useful for producing diagnostic >information.) Operand_List_Type would be an unconstrained array type of >pointers to Operand_Type'Class objects. > >Instruction_Type'Class would be used in defining a type for instruction >lists. Each optimization pass could be a procedure taking an instruction >list as an in out parameter. It would invoke dispatching operations of >instructions to manipulate instruction lists, but an optimization pass >would not itself be a dispatching operation, on instructions, instruction >lists, or anything else. > >-- >Norman H. Cohen ncohen@watson.ibm.com