Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion How much use of CLOS?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tim Bradshaw  
View profile  
 More options Oct 15 2002, 4:52 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@cley.com>
Date: 15 Oct 2002 09:52:41 +0100
Local: Tues, Oct 15 2002 4:52 am
Subject: Re: How much use of CLOS?

* Peter Seibel wrote:
> This is, I guess, a poll. I'm interested in how experienced Lisp users
> would describe their use of CLOS:
>  a) Always. I never use a defun or defstruct, may God smite me down if
>     I do.
>  b) Sometimes. When appropriate. But sometimes it's just not worth it.
>  c) Never. OO is nothing but media hype. It's too bad Common Lisp had
>     to get poluted with it.

Well, like all sensible people I'm in (b)[1].  Quite apart from anything
else, using structures and CLOS is not mutually exclusive: Lisp
actually *is* an object oriented language, unlike Java, so in Lisp
everything is an object, including structures and integers, functions,
strings &c.  There are no bogus `not an object' things in the language
put there in some half-witted attempt to make the language design
`simpler' or `more efficient' while screwing everyone who ever wants
to use the thing.  Further, structures actually have single
inheritance - in other words they provide an inheritance system as
powerful as anything Java gives you.

    (defstruct a
      x y)

    (defstruct (b (:include a))
      z)

    (defgeneric grind (x)
      (:method ((x a))
        (+ (a-x x) (a-y x)))
      (:method ((x b))
        (+ (b-z x) (call-next-method)))
      (:method ((x number))
        x))

Secondly, I use functions when I don't intend the behaviour I'm
defining to be extensible, or when there are no obvious objects in the
game.  For instance, I have a function (which Erik would hate, with
good reason) PRETTY-DATE-STRING, which prints a pretty date string.
It takes one optional argument, which is a universal time, the default
being (get-universal-time).  Making it a GF would be kind of strange,
because it has no arguments...

Again, Lisp has been well-designed - there is no syntactic difference
between code which uses GFs and code that uses ordinary functions.
Therefore, if I design using plain functions but then decide I want to
change to GFs, for whatever reason, nothing other than the definitions
of my functions/GFs need change.  Compare with C++, say which has two
syntaxes, forcing a big up-front decision about whether to use
functions of methods, or changes to all client code when that decision
changes. Java seems to have done this somewhat better.

--tim

Footnotes:
[1]  Yes, if you are not in (b) you are not sensible and must be
     terminated.  Please do not leave your house, the black
     helicopters will arrive shortly.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.