guile-user
[Top][All Lists]
Advanced

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

Re: GOOPS question


From: Mikael Djurfeldt
Subject: Re: GOOPS question
Date: Fri, 30 Apr 2021 12:43:30 +0200

The superclass question is a matter of taste.

First note that in CLOS-like objects systems, such as GOOPS, methods are
not components of classes but it is rather the set of operations =
generics/methods around a type which define its behavior. Roughly speaking,
the only things directly tied to the class are the slots. In this regard
<array> is opaque---there are no accessible slots. Therefore, if using it
as a superclass, it won't add any slots to your instances apart and above
what you explicitly add in your class definition. So, you should think of
the role of <array> as a superclass more in terms of natural grouping, and
its role in selecting methods when you operate on the object using
generics, than anything else. The *only* functional effect of using <array>
as a superclass in this case is that methods taking an <array> argument
will also accept instances of <gvector> as an argument. (This does not
apply to *functions* now taking array as an argument.)

I would say that you could choose between having no explicit superclass and
having <array> as superclass. In your case there would not be any big
functional difference.

If you, in your last answer, by "template" refer to my answer, then you are
of course free to replace all <vector> stuff with the corresponding <array>
stuff.

In my example, I chose to use <vector> as superclass because I regarded
<gvector> to be a specialization. It is true that <vector> logically could
be regarded as a specialization of <gvector>, but you can't do anything
about that.

Best regards,
Mikael

On Fri, Apr 30, 2021 at 11:48 AM Damien Mattei <damien.mattei@gmail.com>
wrote:

> thank for your answer but my question was just about use of superclass....
> SRFI implementation is too complex  for what i want to do now,
> template is 1 dimension gvector, that's neolithic for me :-) and do not
> explain use of superclass...
> Damien
>
> On Fri, Apr 30, 2021 at 9:57 AM Linus Björnstam <
> linus.internet@fastmail.se>
> wrote:
>
> > This does not answer your question, but:
> >
> > There was just a SRFI released for growable vectors. I don't know about
> > any interest to have it included in guile, but the reference implentation
> > is probably trivially portable:
> > https://srfi.schemers.org/srfi-214/srfi-214.html
> >
> >
> >
> > --
> >   Linus Björnstam
> >
> > On Fri, 30 Apr 2021, at 01:10, Damien Mattei wrote:
> > > hi,
> > > i want to create a growable vector class in Guile,
> > > such as std::vector or python list,
> > > first i do not know if it exist already? seems not
> > >
> > > i want to use GOOPS but i do not understand how the superclass could be
> > > accessed,used, instanciate...
> > > for example in the doc there is:
> > > (define-class <my-complex> (<number>) r i #:name "Complex")
> > >
> > > seems <number> superclass is of no use
> > >
> > > for my growable vector i would like to use array as superclass?
> > > but perhaps should it be just a slot as array are a subset of growable
> > > array ,so a subclass
> > >
> > > anyway if i write something ike that:
> > > (define-class <gvector> (<array>) .....
> > > how can i use the <array> object?
> > >
> > > i think perhaps i should not define a superclass or <object> as super
> > > class....
> > > any advice welcome...
> > >
> > > Damien
> > >
> >
>


reply via email to

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