Lisp Usenet classics

Here are some past Erik Naggum Usenet articles for your reading pleasure.

Tags:

Comments

Re: Object Orientation and what it means in Common Lisp

Dogs don't talk.

(Anonymous)

Re: Object Orientation and what it means in Common Lisp

Clearly you've never met a husky.

Re: Object Orientation and what it means in Common Lisp

In Tennessee, a guy sees a sign in front of a house: "Talking Dog for Sale."

He rings the bell and the owner tells him the dog is in the backyard. The guy goes into the backyard and sees a black mutt just sitting there.
"You talk?" he asks.

"Yep," the mutt replies.

"So, what's your story?"

The mutt looks up and says, "Well, I discovered this gift pretty young and I wanted to help the government, so I told the
CIA about my gift, and in no time they had me jetting from country to country, sitting in rooms with spies and world leaders, because no one figured a dog would be eavesdropping. I was one of their most valuable spies eight years running."

"The jetting around really tired me out, and I knew I wasn't getting any younger and I wanted to settle down. So I
signed up for a job at the airport to do some undercover security work, mostly wandering near suspicious characters and listening in. I uncovered some incredible dealings there and was awarded a batch of medals. Had a wife, a mess of puppies, and now I'm just retired."

The guy is amazed. He goes back in and asks the owner what he wants for the dog.

The owner says, "Ten dollars."

The guy says, "This dog is amazing. Why on earth are you selling him so cheap?"

The owner replies, "He's such a liar. He didn't do any of that shit."

(Anonymous)

Re: Object Orientation and what it means in Common Lisp

Sure, maybe its not the best example... but its just a simple example to express my issue.

Re: Object Orientation and what it means in Common Lisp

Ok, say that dogs talk by barking, but they only have one thing to say all the time.

The thing a particular instance or class has say could be considered a property of the instance or class, not of the talk operation. So you might have classes that look like:

(defclass dumb-animal ()
  ((on-its-mind :initarg :on-its-mind :reader on-its-mind)))

(defclass enlightened-thinker ()
  ((on-its-mind :initarg :on-its-mind :accessor on-its-mind)))

(defclass dog (dumb-animal)
  ((on-its-mind :allocation :class))
  (:default-initargs :on-its-mind "Woof!"))

(defclass chicken (dumb-animal)
  ((on-its-mind :allocation :class))
 (:default-initargs :on-its-mind "Bock bock bock!"))

(defclass person (enlightened-thinker)
  ())

(defun say (stuff)
  (write-line stuff))

(defgeneric speak-your-mind (thing)
  (:method (thing)
    (say (on-its-mind thing))))

(defmethod slot-unbound (class (object enlightened-thinker)
                         (slot-name (eql 'on-its-mind)))
  (error "Nothing on your mind?"))



A person might change what is on his mind, but a dog or chicken won't.

Anyway, you can model everything you want to in CLOS; it helps to understand what's with the grain and what isn't.

September 2014

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