On Jun 7, 2010, at 1:41 PM, Jeff Johnson wrote: > > (aside) > I almost added a RPN calculator to popt-1.16 this weekend past. > The implementation would have involved a table entry like > > int counter = 0; > > { "autoincrement", '\0', POPT_ARG_INT|POPT_ARGFLAG_RPN, &counter, 0, > N_("Demonstrate autoincrmenting using a RPN calculator"), "1 +" }, >
Well I finally implemented autoincrement using a RPN calculator with a table entry (from popt/test1.c) like { "verbose", 'v', POPT_ARG_VAL|POPT_ARGFLAG_CALCULATOR|POPT_ARGFLAG_DOC_HIDDEN, &aCounter, 1, "POPT_ARGFLAG_CALCULATOR: increment a counter", "+" }, I almost certainly will change my mind as I proceed wiring up RPN "calculator" functionality somehow. There are several things I dislike with what I implemented, basically lack of generality and too arcanely obscure to be useful (imho). Specifically the implementation: 1) "works" only with longs/ints/shorts, not floats/doubles. 2) has a delta increment that is limited to 32 bits and must be specified as "1" (a variant of the need for an additional "incompatible" pointer field) 3) no clue how to display RPN calculator +/- in --help. Note that the implementation already does more than "++" and "--", that would be easy to add to --help spewage somehow. 4) will force the 7th table field to be used for POPT operations, not just information in --help. todo++ still early yet for POPT 2.0 73 de Jeff ______________________________________________________________________ POPT Library http://rpm5.org Developer Communication List popt-devel@rpm5.org