unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Panicz Maciej Godek <godek.maciek@gmail.com>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-user@gnu.org
Subject: Re: A mess with GOOPS
Date: Mon, 5 Sep 2011 23:35:28 +0200	[thread overview]
Message-ID: <CAMFYt2Yz=FazWF=qfuodnE6DWQ_=Ga01hkH1SQDgF6FRncfRkg@mail.gmail.com> (raw)
In-Reply-To: <87y5y5230u.fsf@pobox.com>

I've been trying to add the superclass.
Adding it to <vector> and <bytevector> turned out
to be extremely simple, but the problem emerged
when I was trying to generalize the <array> class.

The thing is that <array> is implemented as a smob,
and that there is no easy way to add a superclass
to a class created from smob.

I can think of a number of ways of making
a workaround, but all of them are nasty. Each
of them will require the modification of
goops.c: create_smob_classes.

The first way would be to check whether
!strcmp (SCM_SMOBNAME (i), "array")
and to behave appropriately when it happens.

But that would be just ugly.

The other two ways that come to my mind would be:
1. to modify the type `scm_smob_descriptor', adding
SCM supers; /* list of superclasses */

or, equivalently
2. to add a new global array,
SCM_API SCM smob_supers[MAX_SMOB_COUNT], such
that their default would either be SCM_EOL, or
scm_list1(scm_class_top).

The other idea would be to mess with
scm_sys_inherit_magic_x and add a superclass
after the creation of "<array>", but that doesn't
sound too sound (at least for as long as this action
is undocumented)

So to me it seems that adding the <generalized-array>
(or however should it be called) that would be the
ancestor of "array" requires some changes in the
guile API. I wouldn't do it without the overall approval.

Best regards
M.


2011/9/3, Andy Wingo <wingo@pobox.com>:
> Hi Panicz,
>
> On Fri 02 Sep 2011 21:53, Panicz Maciej Godek <godek.maciek@gmail.com>
> writes:
>
>> In other words, classes <vector>, <uvec> and <array> have nothing in
>> common, which requires me to triple the number of methods that could
>> accept any of these types.
>
> We should fix this.  We can probably do it in 2.0.  Interested in
> sending a patch?
>
> Currently this stuff is in C, unfortunately.  Perhaps it should move to
> Scheme at some point, but if you just wanted to add an <array> or
> <generalized-vector> superclass, see goops.c.  Look for the <uvec> stuff
> and follow the patterns.
>
> Andy
> --
> http://wingolog.org/
>



  reply	other threads:[~2011-09-05 21:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-02 19:53 A mess with GOOPS Panicz Maciej Godek
2011-09-03 13:01 ` Andy Wingo
2011-09-05 21:35   ` Panicz Maciej Godek [this message]
2011-09-05 22:47     ` Panicz Maciej Godek
2011-09-06 10:17       ` Panicz Maciej Godek
2011-09-06 11:06         ` Panicz Maciej Godek
2012-01-09 17:11     ` Andy Wingo
2012-01-10 12:22       ` Daniel Llorens
2012-01-11 23:57         ` Daniel Llorens
     [not found] <mailman.173.1315324889.11781.guile-user@gnu.org>
2011-09-06 17:07 ` Daniel Llorens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMFYt2Yz=FazWF=qfuodnE6DWQ_=Ga01hkH1SQDgF6FRncfRkg@mail.gmail.com' \
    --to=godek.maciek@gmail.com \
    --cc=guile-user@gnu.org \
    --cc=wingo@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).