home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.object
- Path: sparky!uunet!cs.utexas.edu!convex!news.utdallas.edu!corpgate!bnrgate!nrcnet0!cunews!cunews!knight
- From: knight@mrco.carleton.ca (Alan Knight)
- Subject: Re: How FUNCTION be OPJECTS?
- Message-ID: <knight.713802652@cunews>
- Sender: news@cunews.carleton.ca (News Administrator)
- Reply-To: knight@mrco.carleton.ca (Alan Knight)
- Organization: Carleton University
- References: <1992Aug10.224351.17853@lut.ac.uk> <1992Aug11.092606.30171@m.cs.uiuc.edu> <STEVE.92Aug11165341@diana.Advansoft.COM>
- Date: Fri, 14 Aug 1992 14:30:52 GMT
- Lines: 32
-
- In <STEVE.92Aug11165341@diana.Advansoft.COM> steve@Advansoft.COM (Steve Savitzky) writes:
-
- >The time when you *really* need functions to be objects is when you
- >need to pass a function as an operand (e.g. to a sort method) or keep
- >it as part of some object's state (e.g. a graph widget).
-
- >Languages like Smalltalk make life difficult by having two
- >incompatible representations for functions used in this way: as a
- >block or as the name of a method.
-
- In Smalltalk the normal way of doing this is to pass blocks, method
- names are uncommon.
-
- There is an advantage to method names. The method "perform:" can be
- considerably faster than "value". This is certainly true in
- Smalltalk/V. I'm not sure if the optimization of simple blocks in
- ObjectWorks succeeds in getting rid of this overhead or not. I
- implemented something that avoided the incompatability by defining
- additional methods so that the two could be used interchangeably. I
- actually used
-
- blockOrString applyTo: obj1 and: obj2 ...
-
- although there's no reason you couldn't have implemented value,
- value:value: etc. for strings or perform:, perform:with: etc for
- Strings.
-
- --
- Alan Knight knight@mrco.carleton.ca +1 613 788 2600x5783 Join
- Dept. of Mechanical and Aerospace Engineering the
- Carleton University, Ottawa, Ontario, Canada, K1S 5B6 LPF
-
-