This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: curses-based widget sets for guile


On Fri, 21 Aug 1998, Klaus Schilling wrote:

> I first wanted to write them in C and poke them through the gh interface, but
> as there are only 255 smobs for disposal, I thought that would cause a problem 
> for some applications, when each widget type gets its own smob type. Or is 
> there a way around it? First experiments with my menu type showed that 
> it might load like a frozen snail.

In my experience, it's a good solution to have one smob type for each base
class only:

struct base_class {
    type_info type;
    data ....
}

struct derived_1 {
    base_class base;
    additional data...;
}

Then you can have type predicates for each of the derived types by 
1) testing the scheme object to be a base type smob.
2) then, test for base::type_info to be of the appropriate type.

This way you avoid to have smobs for each of the derived types.
Assuming you have a widget base class, you will only need one smob for all
widgets.

Best regards, 
Dirk Herrmann