guile-user
[Top][All Lists]
Advanced

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

Re: smob gc protection, and inheritance


From: Andy Wingo
Subject: Re: smob gc protection, and inheritance
Date: Sat, 07 Sep 2013 10:22:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

On Tue 03 Sep 2013 21:27, Doug Evans <address@hidden> writes:

> 2) Is it possible to inherit, e.g., with goops, a smob?
> IOW, can I extend a smob through inheritance?
> Or must I store the smob in a class, and provide accessors?
> [kinda like the "is a" vs "has a" relationship]

You can't really inherit from a SMOB in GOOPS.  SMOB types have
corresponding GOOPS classes, but in a practical sense they can only be
used as specializers on methods; they aren't useful as constructors or
superclasses.  This is because GOOPS objects and SMOB objects have
different representations.

It's possible to do SMOB-like things in GOOPS but it is tricky and not
well documented.  Guile-GNOME does this; see
http://git.savannah.gnu.org/cgit/guile-gnome.git/tree/glib/gnome/gobject/gtype.scm
for more.

Lately what I have been doing is just using the FFI, and setting
finalizers on pointers as needed.

Regards,

Andy
-- 
http://wingolog.org/



reply via email to

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