subtle "algorithm" definition issue.
Matthias Andree
matthias.andree at gmx.de
Sun Nov 3 19:57:40 CET 2002
On Sun, 03 Nov 2002, David Relson wrote:
> The statement in bogofilter.h wasn't intended to declare the variable. It
> probably should be the enum statement in your change. However, when I do
> that, I see that global variable "algorithm" is used in programs
> bogofilter, bogoutil, configtest, and debugtest. Bogofilter has at least
> one other global variable that I see declared in the main routines of
> several programs, i.e. run_type.
Well, yes.
> This, and the implementation of config.c, leads to the broader questions:
>
> Where do global variables belong?
> Where do variables for configuration options belong?
setup_lists does not need the algorithm. It's only ever called from
main.c, and I have main.c now pass in the good/bad weights, with the
latter fixed to 1.0 and the former to whatever GOOD_BIAS expands to. (We
might consider making GOOD_BIAS a function though.)
That way, the global variable which does definitely not belong into
wordhash.? can be kept out of this.
> The answer that comes to mind first is:
>
> create a globals.c to hold run_type, algorithm, etc.
> use config.c as the home for configuration options.
>
> I suspect some variables fit both categories (config and global). I doubt
> there'll be any code in globals.c, so maybe it shouldn't even
> exist. Perhaps we should put them all in config.c.
I believe we have a problem with the interfaces, not with where the
variables are. We should review all interfaces and make sure they are
complete -- global variables usually give the hint that some interface
is not powerful enough.
Passing in a handle for the configuration should be fair enough.
--
Matthias Andree
More information about the bogofilter-dev
mailing list