guile-devel
[Top][All Lists]
Advanced

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

Re: goops C interface


From: Carl R. Witty
Subject: Re: goops C interface
Date: 27 Oct 2000 11:37:30 -0700

Eric Moore <address@hidden> writes:

> 1) do people prefer some kind of giant varargs style function that
>    defines a class, or one that takes a struct that defines it?

The latter.  It's been my experience that giant varargs functions tend
to grow uglier and uglier.

In fact, I like APIs like this:

  class_definition_struct cds;

  init_class_definition_struct(&cds);

  cds.name = "foo";
  cds.slots = ...;

  define_class(&cds);

That means you can add new fields to class_definition_struct, give
them sensible default values, and old code will continue to work with
only a recompile.

With a bit more work, you can set things up so that new fields don't
even require a recompile (i.e., so that you can use a newer shared
library, with more fields in class_definition_struct, with an older
executable).  I haven't been building shared libraries when I've used
this technique, so I haven't bothered, but it's worth considering for
this application.

Carl Witty



reply via email to

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