Re: Passing Pointers -- where to delete them
On 4 mar, 17:43, Jeff Schwab <j...@schwabcenter.com> wrote:
James Kanze wrote:
On Mar 3, 5:09 pm, "jason.cipri...@gmail.com"
<jason.cipri...@gmail.com> wrote:
On Mar 3, 5:48 am, James Kanze <james.ka...@gmail.com> wrote:
[...]
[concerning singletons...]
Like most things, they can be overused, but a few special cases
do occur to me.
...
I sometimes use it for command line options if I need to put
something together quickly (even then I try to keep the
command line data local to main and pass around the relevant
parts as needed),
Actually, I've found it preferable for individual components to
handle their own options, with no global specification of the
complete list of options anywhere. At least in a lot of cases.
How do you recognize bad options? Do the components register
their flags in a table somewhere? I also don't keep the
arguments around (except in argv)), but still find I have to
define them all in one place, e.g. in a getopt format string.
It depends on what makes them bad. If it's an unknown option,
of course, CommandLine doesn't find it registered when it
processes argc, argv, and complains (a fatal error). If it's a
problem with an argument to the option (supposing there is one),
that's up to the actual option to handle.
Of course, I still do have to define them all in one place: the
man page:-). (With getopt, of course, I'd have to define them
there as well.)
If you're interested, the code is on line. Not the very latest
version, but these particular components haven't changed that
much. (Or have they? I know I added support for positional
dependent options at one point, things like the -l option of the
compiler. It may not be in the version currently on line.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34