| Unix Content | Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
|
| Aaron W. Hsu wrote: > Hello, > > I am planning on writing some bindings for Motif to Scheme and I had a > question about style. Is it generally considered better Motif style to > use the variable arity procedures or the static arity procedures? I > know that there seem to be plenty of examples of using both, but I can't > tell whether one or the other is a better choice for designing a > consistent style. If by arity you mean XtVaSet... XtVaGet... versue XtGet... XtSet then I would consider XtVa functions to be superior, since you can do more with one call. Also gcc 4 or later will warn you of missing sentinel (ending NULL) in XtVa functions, so it is not so error prone as before. But this is just my opinion, I would not go so far as categorically advise one style over another. Best regards Dušan Peterc http://wwwa.arahne.si |
|
#2
|
| Aaron W. Hsu wrote: > Thanks for your suggestion. In the end, I do not intend the user of these > bindings to see the C parts at all. However, I want to make sure that the > bindings are flexible and easy to maintain for others down the road. > Finding a consistent way of using the large number of Motif procedures > seems like the best way to do this. I assume that both functions are > more or less equal in expressivity? They are exactly the same in their expression power. They are there just to help the programmer in simplifying the code. Actually, all your questions regarding style and motivation are answered in XtVa... sections of Volume 5 X Toolkit Intrinsic Reference Manual Third edition for X11 Release 4 and Release 5 By O'Reilly & Associates, Inc. edited by David Flanagan. This same book is open source book, since it is out of print http://www.archive.org/details/xtool...fman05oreimiss but only the first edition is open sourced. So it does not cover XtVa... functions, which were introduced with X11R4. Fortunately, you can get it at Powells for $8.75 http://www.powells.com/biblio?isbn=1-56592-007-4 Or you can ask O'Reilly to open source the updated versions, too. Even the last edition is 16 years old now. Dušan Peterc http://www.arahne.si |
|
#3
|
| On Jul 21, 3:21*am, arahne > Aaron W. Hsu wrote: > > Thanks for your suggestion. In the end, I do not intend the user of these > > bindings to see the C parts at all. However, I want to make sure that the > > bindings are flexible and easy to maintain for others down the road. > > Finding a consistent way of using the large number of Motif procedures > > seems like the best way to do this. I assume that both functions are > > more or less equal in expressivity? > > They are exactly the same in their expression power. > They are there just to help the programmer in simplifying the code. > > Actually, all your questions regarding style and motivation > are answered in XtVa... sections of > Volume 5 > X Toolkit Intrinsic Reference Manual > Third edition > for X11 Release 4 and Release 5 > By O'Reilly & Associates, Inc. > edited by David Flanagan. > > This same book is open source book, since it is out of printhttp://www.archive.org/details/xtoolkitintrirefman05oreimiss > but only the first edition is open sourced. > So it does not cover XtVa... functions, which were introduced > with X11R4. > Fortunately, you can get it at Powells for $8.75http://www.powells.com/biblio?isbn=1-56592-007-4 > Or you can ask O'Reilly to open source the updated versions, too. > Even the last edition is 16 years old now. > Both have advantages and disadvantages. the XtVa... style allows for a single call, and ease of adding, removing, or commenting out one or more resource settings: XtVaSetValues( widget, resourceName, value, resourceName, value, /* resourceName, value,*/ NULL); But the non-variadic functions have the advantage of not requiring a lot of malloc/free thrashing in the variadic functions, and also allow ease of setting resources based on some condition: n = 0; XtSetValues( arg[n], resourceName, value); n++; if (soemthing) { XtSetValues( arg[n], resourceName, value); n++; XtSetValues( arg[n], resourceName, value); n++; XtSetValues( arg[n], resourceName, value); n++; } XtSetValues( widget, args, n ); Remembering, of course, to dimension the arg array appropriately. The choice is up to you. Personally, I prefer the latter. -- Fred Kleinschmidt |