Re: [gtk-list] Re: A type system for high-level interfaces
- From: Maurizio Vitale <Maurizio Vitale esat kuleuven ac be>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: A type system for high-level interfaces
- Date: 27 Aug 1997 08:04:30 +0200
Marius Vollmer <mvo@zagadka.ping.de> writes:
> Maurizio Vitale <Maurizio.Vitale@esat.kuleuven.ac.be> writes:
> >
> > Don't know much about what you're trying to do, but why not making
> > toplevel a scheme symbol whose value is the integer corresponding to
> > the C enumeration tag?
>
> Symbols are the natural choice for enumerations in Scheme. If
> gtk-window-new would have been written in Scheme, it would almost
> certainly take symbols as the enumeration values. Unfortunately, when
> interfacing to C code, this requires a (more or less) costly
> translation into numeric values.
We were talking about the cost of a strcmp over a (possibly sorted)
sequence of strings. If you have only very few possibilities (like in
gtk-window-new) then the fastest thing is probably a nest of IFs [and
still faster a dispatch on an unique character followed by a _single_
strcmp].
But if you've way many possibilities, like colors (I don't know if
you've this problem for gtk) then using the builtin hashing from
strings to values that Guile provides you is probably a good option.
> > Making those symbols part of a gtk module (or prefixed by gtk:) would
> > help alleviating the name pollution problem.
>
> Gtk already has to keep the namespace clean, so that wouldn't be a
> problem in Scheme, I think.
What I meant was that if you've somewhere something to the effect of
(define toplevel GTK_TOPLEVEL) then the user cannot bind anything else
to toplevel, while if you seize all identifiers starting with gtk: for
your interface you've much less problems.
-mav
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]