Re: Re: Gengetopt 2.21 enhancement suggestions

Lorenzo Bettini <[email protected]> Thu, 18 Oct 2007 13:33:46 +0200
Newsgroups gmane.comp.gnu.gengetopt.general
Message-ID <[email protected]>
Papp Gyozo (VBuster) wrote:
>> generated code is going; if you take a look at the current version
>> in CVS you'll see lots of usage of void pointers, unions and switch
>>  statements (with corresponding casts) to deal with different
>> types... this is why I love C++'s polymorphism and really don't
>> like C ;-)
> 
> OK, I'll check it if I have a little time.
> 
> Last when I was dealing with gengetopt's source refactoring I had a
> feeling that using type-specific callbacks may be a good approach. I
> mean different callbacks for options of type integer, floats and
> string. But now I don't know how far you have got in refactoring.

actually, in this refactoring, there's only one update function for all 
the options (and one for multiple options which of course rely on the 
former); although this required some time to write that generic function 
correctly, then, its usage is simpler (especially for adding 
functionalities).  For instance, now the main switch statement is 
cleaner (since it only calls this function, unless for group updates 
which is still there)

The only problem is that generic in C means either void * or unions and 
lots of conversions.

having different functions for each time might lead to code bloat, and 
are harder to maintain...

cheers
	Lorenzo

-- 
Lorenzo Bettini, PhD in Computer Science, DSI, Univ. di Firenze
ICQ# lbetto, 16080134     (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net