[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Historical syntax query

rvirding

5/30/2016 1:35:00 PM

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
3 Answers

Rainer Joswig

5/30/2016 2:50:00 PM

0

On 2016-05-30 13:35:15 +0000, Robert Virding said:

FYI: Lisp Machine Lisp had a CLASS system (with DEFCLASS) before it had
Flavors and long before CLOS:

http://lispm.de/source/lispm-system-78-48/lispm2/...


> 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


Barry Margolin

5/31/2016 1:03:00 AM

0

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 ***

Marco Antoniotti

5/31/2016 6:05:00 PM

0

On Tuesday, May 31, 2016 at 3:02:39 AM UTC+2, Barry Margolin wrote:
> 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.

Actually all defining forms are like

(def <what> <some spec> ...)

As long as you use DEFINER (from common-lisp.net) :) :) :)

Cheers
--
MA