Re: XForms: Global data

Steve Lamont (spl@szechuan.ucsd.edu)
Thu, 12 Mar 98 19:34:59 PST

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> > I'm new at programming in X, and XForms is the first library I've really
> > looked at in detail. I'm curious if there's a way to avoid using global
> > data for a program using XForms? ...

> I'm writing a particle system in c/XForms and I've given up using
> callbacks for anything serious. You have discovered the point
> where, IMO, the forms library breaks down doing serious programming.

I don't wish to criticize anyones particular programming style or to
cast aspersions on anyone's ability as a programmer (I, too, am
largely self taught) but this is absolutely wrong. I have developed
"serious" programs which are thousands of lines of code and there is
not a single global variable referenced other than system provided
things like errno.

> The xforms solution is to do this. In your "form".h you'll see...
>
> typedef struct {
> void *vdata;
> char *cdata;
> long ldata;
>
> you can use these variables to pass data around. It's a kludge and your
> better off grabbing the fl_do_forms()/fl_check_forms() output and writing
> your own functions.

On the contrary, this is a useful mechanism for providing context.
I'd even go so far as to call it somewhat elegant.

Create the appropriate data structure, hang it on vdata or the Form or
Object u_vdata, as appropriate, and you have exactly what you need to
pass information between callback functions, forms, and objects with
facility.

Your mileage, of course, may vary.

spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/