Simple polymorphism in Common Lisp

Discussion of Common Lisp

Re: Simple polymorphism in Common Lisp

Postby lispamour » Mon Jul 26, 2010 3:13 am

Ramarren wrote:Also CLOS is rather different from most object system, being verb centered rather than noun centered, which I have always found to be a nice compromise between functional and object styles, as long as one is able to think in terms of those verbs, and protocols, rather than primarily focusing on classes and objects, which happens to a lot of people coming from C++/Java backgrounds.


I think I understand what you mean by verb-centered rather than noun-centered: In typical single receiver OO languages the invocation is
object message


in which the receiver acting as the noun is the primary entity, whereas in Lisp, we have
(function object-1 ... object-n)

in which the function, taking on the role of the verb, has primacy.

Can you elaborate a bit on what you mean by protocols? I can guess, but I'd like to be sure...
lispamour
 
Posts: 18
Joined: Wed Jun 02, 2010 12:29 am

Re: Simple polymorphism in Common Lisp

Postby ramarren » Mon Jul 26, 2010 3:29 am

lispamour wrote:Can you elaborate a bit on what you mean by protocols? I can guess, but I'd like to be sure...


What I meant by protocols is that the primary object oriented program unit should be a set of generic functions, with methods specialized on some objects which might or might not be connected through class inheritance hierarchy to other specializations. This is generally referred to this days as duck typing.
ramarren
 
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland

Re: Simple polymorphism in Common Lisp

Postby findinglisp » Sun Sep 19, 2010 6:16 am

Ramarren wrote:Paul Graham never really liked Common Lisp as such, which means that style used in his books is rather idiosyncratic. And it is telling that his language is rather Scheme like and based of Scheme.

I agree that functional style is elegant and usually useful, but there are certain problem domains where it just doesn't fit, which is one of the primary drawbacks of Haskell. Trying to avoid OO style usually leads to reinventing it badly when trying to work in such domain, so it is best to have available many different approaches.

Also CLOS is rather different from most object system, being verb centered rather than noun centered, which I have always found to be a nice compromise between functional and object styles, as long as one is able to think in terms of those verbs, and protocols, rather than primarily focusing on classes and objects, which happens to a lot of people coming from C++/Java backgrounds.


I'm not sure I would go so far as to say that Graham doesn't like Common Lisp. In fact, I think he's firmly in the CL camp, particularly as regards macro systems. I think he has an appreciation of Scheme, however, as every Lisper should.

Now, that said, I don't think he likes CLOS. I think he prefers a functional style and sees CLOS as a deviation from that style. Given that Lisp, and particularly CL, is a multi-paradigm language, I don't see anything wrong with that. If you read Practical Common Lisp, you'll get a good treatment of CLOS used in really interesting ways. Conversely, ANSI Common Lisp gives it one strictly-factual chapter and little else. Both are worth reading, but give very different insights into Lisp style. Read both and choose your own style.
Cheers, Dave
Slowly but surely the world is finding Lisp. http://www.findinglisp.com/blog/
findinglisp
 
Posts: 440
Joined: Sat Jun 28, 2008 7:49 am
Location: Austin, TX

Re: Simple polymorphism in Common Lisp

Postby kelvinkammeron » Fri Dec 07, 2018 3:40 am

Any Java object that can pass more than one IS-A test is considered to be polymorphic. In Java http://www.dhakshatech.com all objects are polymorphic since any object will pass the IS-A test for their own type and for the class Object.It is important to know that only possible way to access an object is through a reference variable. A reference variable can be only one type. Once declared, the type of reference variable cannot be changed.
kelvinkammeron
 
Posts: 1
Joined: Fri Dec 07, 2018 3:32 am

Previous

Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 7 guests

cron