Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!nosc!ucsd!ucsdhub!hp-sdd!hplabs!hpda!hpcuhb!hp-sde!hpcea!hpdtl!weeks From: weeks@hpdtl.HP.COM (Gregory Weeks) Newsgroups: comp.lang.smalltalk Subject: implementing nonintrusive procedures Message-ID: <7180001@hpdtl.HP.COM> Date: 8 Sep 88 19:18:52 GMT Organization: HP Design Tech. Lab., Palo Alto, CA Lines: 23 I'm aware that the message-sending paradigm of Smalltalk doesn't smoothly handle all situations. There is one situation in particular that I'm curious about. Suppose I have a useful procedure in mind that accesses its argument only by sending it certain messages. Suppose further that I want to be able to apply this procedure to any object that recognizes these messages. There are many ways to implement such a procedure. 1. For every target class [that is, for every class that recognizes the messages used in the procedure], define a method that implements the procedure. 2. Arrange somehow for all of the target classes to have a common superclass and implement the procedure as a superclass method. 3. Define a block that implements the procedure and bind it to a global variable. 4. Implement the procedure as a method of a nontarget class. Are some of the above choices clearly superior? Is there an established Smalltalk style that rules out some of the choices?