Barry Margolin
5/31/2016 1:03:00 AM
In article <23a85458-e885-46c6-9ab5-d68c3b915e68@googlegroups.com>,
Robert Virding <rvirding@gmail.com> wrote:
> Defining structs and classes needs very similar types of parameters. You need
> a struct/class name, struct/class options and struct components or class
> slots (these are pretty much the same thing). For classes you can also have
> super classes. However the syntax for defining is different:
>
> (defstruct (<struct-name> <struct-options>)
> <components>
> )
>
> (defclass <class-name>
> <super-classes>
> <slots>
> class-option
> ...
> )
>
> Does anyone know WHY they are different? Is there any fundamental reason for
> them to be different? Or was it just what the guy who implemented them that
> decided this?
>
> Both of these features pre-data CL. They were at least in Lisp Machine lisp
> (though classes were called flavors) were they had the same basic different
> structures so the CL syntax is not new. My question then goes further back.
>
> I know this question is basically irrelevant but it would be interesting to
> know if there was reason it became like this, or did it just happen?
>
> Robert
Most defining macros are of the form
(defWHATER <whatever-name> ...)
DEFSTRUCT is the odd man out in this pattern, and I guess the creators
of DEFCLASS didn't want to copy that mistake.
It also may be related to the fact that DEFSTRUCT was originally created
for MACLISP, which didn't have keywords. So there was no way to put
structure options in the body along with the list of slots -- they would
look like slot definitions. But when DEFCLASS was created, we could
depend on the fact that keywords can't be used as slot names, so a list
beginning with a keyword must be a class option rather than a slot
specification.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***