guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: goops proposal: proper struct classes


From: Andy Wingo
Subject: Re: goops proposal: proper struct classes
Date: Tue, 22 Nov 2011 23:23:00 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

Hi,

Just some more details here, to get this off the back of my queue:

On Sun 01 May 2011 22:19, Andy Wingo <address@hidden> writes:

> If you know GOOPS, then you know that we have classes, rooted at
> <class>.  And indeed <class> shows up a lot in documentation and in
> code.  But that's not how it is in CLOS: our <class> corresponds to
> their `standard-class'.  They have a superclass, called `class', which
> is the real root, and from which e.g. structure classes are derived.

>From CLISP:

    [1]> (defstruct foo)
    FOO
    [2]> (class-of (make-foo))
    #<STRUCTURE-CLASS FOO>
    [3]> (class-of (class-of (make-foo)))
    #<STANDARD-CLASS STRUCTURE-CLASS>
    [4]> (class-precedence-list (class-of (make-foo)))
    (#<STRUCTURE-CLASS FOO> #<STRUCTURE-CLASS STRUCTURE-OBJECT>
     #<BUILT-IN-CLASS T>)
    [5]> (class-precedence-list (class-of (class-of (make-foo))))
    (#<STANDARD-CLASS STRUCTURE-CLASS>
     #<STANDARD-CLASS CLOS::SLOTTED-CLASS>
     #<STANDARD-CLASS CLASS>
     #<STANDARD-CLASS CLOS::POTENTIAL-CLASS>
     #<STANDARD-CLASS SPECIALIZER>
     #<STANDARD-CLASS CLOS::SUPER-CLASS>
     #<STANDARD-CLASS STANDARD-STABLEHASH>
     #<STANDARD-CLASS METAOBJECT>
     #<STANDARD-CLASS STANDARD-OBJECT>
     #<BUILT-IN-CLASS T>)

> We need to do this.  Currently, class-of on a struct/record data type
> gives a useless class that can't instantiate instances, doesn't know its
> slots, and does not reflect the vtable hierarchy.

A slightly different case, but FWIW:

    scheme@(guile-user)> (class-precedence-list (class-of 1))
    $1 = (#<<class> <integer> 17ad960>
          #<<class> <real> 17ada50>
          #<<class> <complex> 17adb40>
          #<<class> <number> 17adc30>
          #<<class> <top> 1172690>)
    scheme@(guile-user)> (class-precedence-list (class-of (class-of 1)))
    $2 = (#<<class> <class> 1172780>
          #<<class> <object> 11725a0>
          #<<class> <top> 1172690>)

> So we need a <basic-class>, interposed between <class> and <object>,
> which will be the real root of our class meta-object hierarchy.

This is almost right: we do need <basic-class> in the cpl between
<class> and <object>, but <class> (and <basic-class> and, later,
<struct-class>) should still be an instance of <class>.

Andy
-- 
http://wingolog.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]