An anonymous user wrote
on October 4th, 2007 at 03:40 am

Re: Object Orientation and what it means in Common Lisp

This is such an excellent post and I do miss the insightful posts of Erik Naggum.

I must admit though, I have never really gel'd with CLOS, or could never wrap my head around it entirely.

He makes a comment..

"It is not classes that experienced Common Lisp programmers start with. It is the generic functions."

and I do wish there was a good example or tutorial out there which really helped to turn the light on for me and others regarding this.

One of the stumbling blocks is how generic methods must be congruent. Which just seems so foreign coming from a message passing OO language. Its not uncommon to have two methods with the same name but which take a different number of arguments.

For example,

A dog talks although it just says "woof" and so does a human. But a human can say anything.

So a dog might may have a method, talk, which takes no arguments and it just spits out "woof"

and a human might have a method talk: msg, which takes an arugment with text to speak.

I've had someone tell me to just create a talk generic method which takes an argument to specialize on and a second argument msg. When the specialized argument is dog, ignore the msg argument, but when it's human, use the msg argument.

This just seems weird from a standpoint of using the code and trying to understand what I need to pass in. Just making the method more convoluted so that it handles the most complex case? And what happens in the future if I need to add another argument (what happens to all the old calls)?

If you have any suggestions to shed light on this.. I'm all ears... as I would love to really finally get over this... and again, thanks for the great post.

(Read Comments)

No HTML allowed in subject

  
 
   
 

Notice! This user has turned on the option that logs your IP address when posting. 

(will be screened)

September 2014

S M T W T F S
 123456
78910111213
14151617181920
21222324252627
282930    
Powered by LiveJournal.com