From: Ryan Pavlik Date: 2003-09-04T03:30:23+09:00 Subject: Re: OOP flavors - was Re: Python vs. Ruby On Wed, 3 Sep 2003 23:21:59 +0900 Brian Candler wrote: > But perhaps more importantly: we expect the receiver of a message to modify > its state, not the sender. > > item.push(stack) > > would be sending a message to the item to push itself onto a particular > stack; the item would be unchanged by the action, but the stack would be > changed. This is getting very close to the procedural > > push(stack,item) > > since the 'push' method would need to know about the internal instance > variables and organisation of a stack in order to be able to update it. And > then that logic would have to be put into every possible type of 'item' that > you wanted to be able to push onto a stack ! Careful. This is no more procedural than "stack.push(item)". Consider the following definition in C: void push(Stack *self, item) { ... } Saying "foo.bar" does not make something more or less object-oriented. Doing OOP in C is perfectly possible (although somewhat trying, as you have to do some things manually), and follows this form exactly. (See the glib/gtk stuff for a more robust, but not terribly great, example.) In fact, some languages, such as ANSI Lisp, do OOP in much this manner. CLOS lets you define generic methods which take the receiver as the second parameter. What defines OOP is Encapsulation, Polymorphism, and Inheritence, not syntax and calling order. ;) -- Ryan Pavlik "Give my regards to the bottom of the ocean, sinky!" - 8BT