Re: [gtk-list] Re: A type system for high-level interfaces



Maurizio Vitale <Maurizio.Vitale@esat.kuleuven.ac.be> writes:
> 
> Marius Vollmer <mvo@zagadka.ping.de> writes:
> 
> > To explain, what I have in mind for enumerations: You could write this
> > code to create a toplevel window
> > 
> >     (gtk-window-new 'toplevel)
> >[...]
> 
> 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.

But you get better type checking with symbols.  gtk-window-new only
accepts toplevel, dialog and popup as window types.  With numerical
values, it would also accept GTK_UPDATE_CONTINUES, GTK_SCROLL_NONE and
all the other enumeration literals.

Anyway, I see no problem with allowing both.

> 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.



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