Re: [gtk-list] types checking signal/callback functions revisited



> 
> I've been thinking about the problem of checking the types expected
> by callback functions [...] but there are no compile- or run-time checks
> that this is done correctly.
> 
> Now, the only way I can think of actually getting the compiler to
> check this is at function declaration. So, if we defined a macro [....]
> 
> Similar things can be done with all the signal callbacks, and still 
> allow us to keep the simplicity of using gtk_signal_connect.
> 
> Any thoughts or better ways of doing this?
> 

I swapped a few ideas along these lines with Owen(was it?) and some of the
other gurus a month or so ago. They seemed to think that there was a
problem in that everyone (except me) likes to misdeclare the callback
functions to something like:

	void callback( GtkWidget *w, GtkWhatever *x )
	{


..rather than what *should* be done, i.e:

	void callback( GtkWidget *w,  gpointer param )
	{
		GtkWhatever *x = param;



Strict type-checking would stop this practice. I say "good!", others
disagree. I've been blown up by some callback parameter mismatches
in my time. I also note that most beginners like me waste a fair bit
of list-bandwidth asking the same questions caused by such problems
that they too are having.

So I say, "go for strong type-checking". It'll save us all time and
trouble in the end.
	

--

Steve                                       | Steve's law of House Rewiring:
S.Hosgood@swansea.ac.uk                     | "No matter how many power sockets
Phone: +44 1792 297292 + ask for Steve      |  you fit in a room, you will run
Fax:   +44 1792 295811                      |  out within the first week of use
--------------------------------------------+  even if you took Steve's law of
http://iiit.swan.ac.uk/~iisteve/steve.html  |  House Rewiring into account"




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