Re: XForms: Global data

Rob Fletcher (rpf1@york.ac.uk)
Fri, 13 Mar 1998 09:35:32 +0000 (GMT)

# To subscribers of the xforms list from Rob Fletcher <rpf1@york.ac.uk> :

On Thu, 12 Mar 1998, Steve Lamont wrote:
>
> > 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 agree Steve. When I first came to FORMS (before it was even XFORMS!),
I too mused on the problems of global data (and objects) within event
based, callback programming!

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

This is the very nice elegant solution. I'm not really sure how else
you would go about passing access to data (of unknown user type and
complexity) by any other means in a simple consistent way. (The other
system I worked with, SUIT, now long past, used the idea of "properties",
which were data-type specfic data items bound to objects. In the end this
was not general enough, but it was much easier for the programmer.) The
idea went like this:

SUIT_set_integer( object, A_NAME, value);

In the object callback you could do:
a_new_value = SUIT_get_integer( me , A_NAME );

A_NAME is a #defined name for the data item,
e.g. #define A_NAME "Button Number"

It would not be hard to write something along these lines as "helper
functions" for XFORMS.

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

Your mileage will depend on getting your head around pointer chains,
but hey, sit down with pen and paper (remember them?), and draw it out,
and it'll become enlightening.

The point of all this is that there are some very good mechanisms
in XFORMS for avoiding global data. They involve some work on behalf of
the user. They have also expanded quite considerably over the last few
years of development, in the main through feedback from the user base,
who really did have these concerns!

Regards, Rob
+===========================+=======================================+
| Dr R P Fletcher (Rob) | Email R.Fletcher@york.ac.uk |
| Graphics Coordinator | Phone +44 1904 433816 (ddi) |
| Computing Service | Frontdesk +44 1904 433800 (ddi) |
| University of York | Fax +44 1904 433740 |
| YORK YO1 5DD, UK | DU Moo Rob_F |
| www.york.ac.uk/~rpf1/ or www.geocities.com/SiliconValley/Bay/8428/|
| The RobCam: www.york.ac.uk/~rpf1/robcam.html |
+===================================================================+

_________________________________________________
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/